
kernel/kernel:     file format elf64-littleriscv


Disassembly of section .text:

0000000080000000 <_entry>:
    80000000:	00009117          	auipc	sp,0x9
    80000004:	84013103          	ld	sp,-1984(sp) # 80008840 <_GLOBAL_OFFSET_TABLE_+0x8>
    80000008:	6505                	lui	a0,0x1
    8000000a:	f14025f3          	csrr	a1,mhartid
    8000000e:	0585                	addi	a1,a1,1
    80000010:	02b50533          	mul	a0,a0,a1
    80000014:	912a                	add	sp,sp,a0
    80000016:	076000ef          	jal	ra,8000008c <start>

000000008000001a <spin>:
    8000001a:	a001                	j	8000001a <spin>

000000008000001c <timerinit>:
// which arrive at timervec in kernelvec.S,
// which turns them into software interrupts for
// devintr() in trap.c.
void
timerinit()
{
    8000001c:	1141                	addi	sp,sp,-16
    8000001e:	e422                	sd	s0,8(sp)
    80000020:	0800                	addi	s0,sp,16
// which hart (core) is this?
static inline uint64
r_mhartid()
{
  uint64 x;
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    80000022:	f14027f3          	csrr	a5,mhartid
  // each CPU has a separate source of timer interrupts.
  int id = r_mhartid();
    80000026:	0007859b          	sext.w	a1,a5

  // ask the CLINT for a timer interrupt.
  int interval = 1000000; // cycles; about 1/10th second in qemu.
  *(uint64*)CLINT_MTIMECMP(id) = *(uint64*)CLINT_MTIME + interval;
    8000002a:	0037979b          	slliw	a5,a5,0x3
    8000002e:	02004737          	lui	a4,0x2004
    80000032:	97ba                	add	a5,a5,a4
    80000034:	0200c737          	lui	a4,0x200c
    80000038:	ff873703          	ld	a4,-8(a4) # 200bff8 <_entry-0x7dff4008>
    8000003c:	000f4637          	lui	a2,0xf4
    80000040:	24060613          	addi	a2,a2,576 # f4240 <_entry-0x7ff0bdc0>
    80000044:	9732                	add	a4,a4,a2
    80000046:	e398                	sd	a4,0(a5)

  // prepare information in scratch[] for timervec.
  // scratch[0..2] : space for timervec to save registers.
  // scratch[3] : address of CLINT MTIMECMP register.
  // scratch[4] : desired interval (in cycles) between timer interrupts.
  uint64 *scratch = &timer_scratch[id][0];
    80000048:	00259693          	slli	a3,a1,0x2
    8000004c:	96ae                	add	a3,a3,a1
    8000004e:	068e                	slli	a3,a3,0x3
    80000050:	00009717          	auipc	a4,0x9
    80000054:	ff070713          	addi	a4,a4,-16 # 80009040 <timer_scratch>
    80000058:	9736                	add	a4,a4,a3
  scratch[3] = CLINT_MTIMECMP(id);
    8000005a:	ef1c                	sd	a5,24(a4)
  scratch[4] = interval;
    8000005c:	f310                	sd	a2,32(a4)
}

static inline void 
w_mscratch(uint64 x)
{
  asm volatile("csrw mscratch, %0" : : "r" (x));
    8000005e:	34071073          	csrw	mscratch,a4
  asm volatile("csrw mtvec, %0" : : "r" (x));
    80000062:	00006797          	auipc	a5,0x6
    80000066:	d3e78793          	addi	a5,a5,-706 # 80005da0 <timervec>
    8000006a:	30579073          	csrw	mtvec,a5
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    8000006e:	300027f3          	csrr	a5,mstatus

  // set the machine-mode trap handler.
  w_mtvec((uint64)timervec);

  // enable machine-mode interrupts.
  w_mstatus(r_mstatus() | MSTATUS_MIE);
    80000072:	0087e793          	ori	a5,a5,8
  asm volatile("csrw mstatus, %0" : : "r" (x));
    80000076:	30079073          	csrw	mstatus,a5
  asm volatile("csrr %0, mie" : "=r" (x) );
    8000007a:	304027f3          	csrr	a5,mie

  // enable machine-mode timer interrupts.
  w_mie(r_mie() | MIE_MTIE);
    8000007e:	0807e793          	ori	a5,a5,128
  asm volatile("csrw mie, %0" : : "r" (x));
    80000082:	30479073          	csrw	mie,a5
}
    80000086:	6422                	ld	s0,8(sp)
    80000088:	0141                	addi	sp,sp,16
    8000008a:	8082                	ret

000000008000008c <start>:
{
    8000008c:	1141                	addi	sp,sp,-16
    8000008e:	e406                	sd	ra,8(sp)
    80000090:	e022                	sd	s0,0(sp)
    80000092:	0800                	addi	s0,sp,16
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    80000094:	300027f3          	csrr	a5,mstatus
  x &= ~MSTATUS_MPP_MASK;
    80000098:	7779                	lui	a4,0xffffe
    8000009a:	7ff70713          	addi	a4,a4,2047 # ffffffffffffe7ff <end+0xffffffff7ffdd7ff>
    8000009e:	8ff9                	and	a5,a5,a4
  x |= MSTATUS_MPP_S;
    800000a0:	6705                	lui	a4,0x1
    800000a2:	80070713          	addi	a4,a4,-2048 # 800 <_entry-0x7ffff800>
    800000a6:	8fd9                	or	a5,a5,a4
  asm volatile("csrw mstatus, %0" : : "r" (x));
    800000a8:	30079073          	csrw	mstatus,a5
  asm volatile("csrw mepc, %0" : : "r" (x));
    800000ac:	00001797          	auipc	a5,0x1
    800000b0:	dc078793          	addi	a5,a5,-576 # 80000e6c <main>
    800000b4:	34179073          	csrw	mepc,a5
  asm volatile("csrw satp, %0" : : "r" (x));
    800000b8:	4781                	li	a5,0
    800000ba:	18079073          	csrw	satp,a5
  asm volatile("csrw medeleg, %0" : : "r" (x));
    800000be:	67c1                	lui	a5,0x10
    800000c0:	17fd                	addi	a5,a5,-1 # ffff <_entry-0x7fff0001>
    800000c2:	30279073          	csrw	medeleg,a5
  asm volatile("csrw mideleg, %0" : : "r" (x));
    800000c6:	30379073          	csrw	mideleg,a5
  asm volatile("csrr %0, sie" : "=r" (x) );
    800000ca:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    800000ce:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    800000d2:	10479073          	csrw	sie,a5
  timerinit();
    800000d6:	00000097          	auipc	ra,0x0
    800000da:	f46080e7          	jalr	-186(ra) # 8000001c <timerinit>
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    800000de:	f14027f3          	csrr	a5,mhartid
  w_tp(id);
    800000e2:	2781                	sext.w	a5,a5
}

static inline void 
w_tp(uint64 x)
{
  asm volatile("mv tp, %0" : : "r" (x));
    800000e4:	823e                	mv	tp,a5
  asm volatile("mret");
    800000e6:	30200073          	mret
}
    800000ea:	60a2                	ld	ra,8(sp)
    800000ec:	6402                	ld	s0,0(sp)
    800000ee:	0141                	addi	sp,sp,16
    800000f0:	8082                	ret

00000000800000f2 <consolewrite>:
//
// user write()s to the console go here.
//
int
consolewrite(int user_src, uint64 src, int n)
{
    800000f2:	715d                	addi	sp,sp,-80
    800000f4:	e486                	sd	ra,72(sp)
    800000f6:	e0a2                	sd	s0,64(sp)
    800000f8:	fc26                	sd	s1,56(sp)
    800000fa:	f84a                	sd	s2,48(sp)
    800000fc:	f44e                	sd	s3,40(sp)
    800000fe:	f052                	sd	s4,32(sp)
    80000100:	ec56                	sd	s5,24(sp)
    80000102:	0880                	addi	s0,sp,80
  int i;

  for(i = 0; i < n; i++){
    80000104:	04c05763          	blez	a2,80000152 <consolewrite+0x60>
    80000108:	8a2a                	mv	s4,a0
    8000010a:	84ae                	mv	s1,a1
    8000010c:	89b2                	mv	s3,a2
    8000010e:	4901                	li	s2,0
    char c;
    if(either_copyin(&c, user_src, src+i, 1) == -1)
    80000110:	5afd                	li	s5,-1
    80000112:	4685                	li	a3,1
    80000114:	8626                	mv	a2,s1
    80000116:	85d2                	mv	a1,s4
    80000118:	fbf40513          	addi	a0,s0,-65
    8000011c:	00002097          	auipc	ra,0x2
    80000120:	356080e7          	jalr	854(ra) # 80002472 <either_copyin>
    80000124:	01550d63          	beq	a0,s5,8000013e <consolewrite+0x4c>
      break;
    uartputc(c);
    80000128:	fbf44503          	lbu	a0,-65(s0)
    8000012c:	00000097          	auipc	ra,0x0
    80000130:	77e080e7          	jalr	1918(ra) # 800008aa <uartputc>
  for(i = 0; i < n; i++){
    80000134:	2905                	addiw	s2,s2,1
    80000136:	0485                	addi	s1,s1,1
    80000138:	fd299de3          	bne	s3,s2,80000112 <consolewrite+0x20>
    8000013c:	894e                	mv	s2,s3
  }

  return i;
}
    8000013e:	854a                	mv	a0,s2
    80000140:	60a6                	ld	ra,72(sp)
    80000142:	6406                	ld	s0,64(sp)
    80000144:	74e2                	ld	s1,56(sp)
    80000146:	7942                	ld	s2,48(sp)
    80000148:	79a2                	ld	s3,40(sp)
    8000014a:	7a02                	ld	s4,32(sp)
    8000014c:	6ae2                	ld	s5,24(sp)
    8000014e:	6161                	addi	sp,sp,80
    80000150:	8082                	ret
  for(i = 0; i < n; i++){
    80000152:	4901                	li	s2,0
    80000154:	b7ed                	j	8000013e <consolewrite+0x4c>

0000000080000156 <consoleread>:
// user_dist indicates whether dst is a user
// or kernel address.
//
int
consoleread(int user_dst, uint64 dst, int n)
{
    80000156:	7159                	addi	sp,sp,-112
    80000158:	f486                	sd	ra,104(sp)
    8000015a:	f0a2                	sd	s0,96(sp)
    8000015c:	eca6                	sd	s1,88(sp)
    8000015e:	e8ca                	sd	s2,80(sp)
    80000160:	e4ce                	sd	s3,72(sp)
    80000162:	e0d2                	sd	s4,64(sp)
    80000164:	fc56                	sd	s5,56(sp)
    80000166:	f85a                	sd	s6,48(sp)
    80000168:	f45e                	sd	s7,40(sp)
    8000016a:	f062                	sd	s8,32(sp)
    8000016c:	ec66                	sd	s9,24(sp)
    8000016e:	e86a                	sd	s10,16(sp)
    80000170:	1880                	addi	s0,sp,112
    80000172:	8aaa                	mv	s5,a0
    80000174:	8a2e                	mv	s4,a1
    80000176:	89b2                	mv	s3,a2
  uint target;
  int c;
  char cbuf;

  target = n;
    80000178:	00060b1b          	sext.w	s6,a2
  acquire(&cons.lock);
    8000017c:	00011517          	auipc	a0,0x11
    80000180:	00450513          	addi	a0,a0,4 # 80011180 <cons>
    80000184:	00001097          	auipc	ra,0x1
    80000188:	a3e080e7          	jalr	-1474(ra) # 80000bc2 <acquire>
  while(n > 0){
    // wait until interrupt handler has put some
    // input into cons.buffer.
    while(cons.r == cons.w){
    8000018c:	00011497          	auipc	s1,0x11
    80000190:	ff448493          	addi	s1,s1,-12 # 80011180 <cons>
      if(myproc()->killed){
        release(&cons.lock);
        return -1;
      }
      sleep(&cons.r, &cons.lock);
    80000194:	00011917          	auipc	s2,0x11
    80000198:	08490913          	addi	s2,s2,132 # 80011218 <cons+0x98>
    }

    c = cons.buf[cons.r++ % INPUT_BUF];

    if(c == C('D')){  // end-of-file
    8000019c:	4b91                	li	s7,4
      break;
    }

    // copy the input byte to the user-space buffer.
    cbuf = c;
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    8000019e:	5c7d                	li	s8,-1
      break;

    dst++;
    --n;

    if(c == '\n'){
    800001a0:	4ca9                	li	s9,10
  while(n > 0){
    800001a2:	07305863          	blez	s3,80000212 <consoleread+0xbc>
    while(cons.r == cons.w){
    800001a6:	0984a783          	lw	a5,152(s1)
    800001aa:	09c4a703          	lw	a4,156(s1)
    800001ae:	02f71463          	bne	a4,a5,800001d6 <consoleread+0x80>
      if(myproc()->killed){
    800001b2:	00001097          	auipc	ra,0x1
    800001b6:	7f8080e7          	jalr	2040(ra) # 800019aa <myproc>
    800001ba:	591c                	lw	a5,48(a0)
    800001bc:	e7b5                	bnez	a5,80000228 <consoleread+0xd2>
      sleep(&cons.r, &cons.lock);
    800001be:	85a6                	mv	a1,s1
    800001c0:	854a                	mv	a0,s2
    800001c2:	00002097          	auipc	ra,0x2
    800001c6:	000080e7          	jalr	ra # 800021c2 <sleep>
    while(cons.r == cons.w){
    800001ca:	0984a783          	lw	a5,152(s1)
    800001ce:	09c4a703          	lw	a4,156(s1)
    800001d2:	fef700e3          	beq	a4,a5,800001b2 <consoleread+0x5c>
    c = cons.buf[cons.r++ % INPUT_BUF];
    800001d6:	0017871b          	addiw	a4,a5,1
    800001da:	08e4ac23          	sw	a4,152(s1)
    800001de:	07f7f713          	andi	a4,a5,127
    800001e2:	9726                	add	a4,a4,s1
    800001e4:	01874703          	lbu	a4,24(a4)
    800001e8:	00070d1b          	sext.w	s10,a4
    if(c == C('D')){  // end-of-file
    800001ec:	077d0563          	beq	s10,s7,80000256 <consoleread+0x100>
    cbuf = c;
    800001f0:	f8e40fa3          	sb	a4,-97(s0)
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    800001f4:	4685                	li	a3,1
    800001f6:	f9f40613          	addi	a2,s0,-97
    800001fa:	85d2                	mv	a1,s4
    800001fc:	8556                	mv	a0,s5
    800001fe:	00002097          	auipc	ra,0x2
    80000202:	21e080e7          	jalr	542(ra) # 8000241c <either_copyout>
    80000206:	01850663          	beq	a0,s8,80000212 <consoleread+0xbc>
    dst++;
    8000020a:	0a05                	addi	s4,s4,1
    --n;
    8000020c:	39fd                	addiw	s3,s3,-1
    if(c == '\n'){
    8000020e:	f99d1ae3          	bne	s10,s9,800001a2 <consoleread+0x4c>
      // a whole line has arrived, return to
      // the user-level read().
      break;
    }
  }
  release(&cons.lock);
    80000212:	00011517          	auipc	a0,0x11
    80000216:	f6e50513          	addi	a0,a0,-146 # 80011180 <cons>
    8000021a:	00001097          	auipc	ra,0x1
    8000021e:	a5c080e7          	jalr	-1444(ra) # 80000c76 <release>

  return target - n;
    80000222:	413b053b          	subw	a0,s6,s3
    80000226:	a811                	j	8000023a <consoleread+0xe4>
        release(&cons.lock);
    80000228:	00011517          	auipc	a0,0x11
    8000022c:	f5850513          	addi	a0,a0,-168 # 80011180 <cons>
    80000230:	00001097          	auipc	ra,0x1
    80000234:	a46080e7          	jalr	-1466(ra) # 80000c76 <release>
        return -1;
    80000238:	557d                	li	a0,-1
}
    8000023a:	70a6                	ld	ra,104(sp)
    8000023c:	7406                	ld	s0,96(sp)
    8000023e:	64e6                	ld	s1,88(sp)
    80000240:	6946                	ld	s2,80(sp)
    80000242:	69a6                	ld	s3,72(sp)
    80000244:	6a06                	ld	s4,64(sp)
    80000246:	7ae2                	ld	s5,56(sp)
    80000248:	7b42                	ld	s6,48(sp)
    8000024a:	7ba2                	ld	s7,40(sp)
    8000024c:	7c02                	ld	s8,32(sp)
    8000024e:	6ce2                	ld	s9,24(sp)
    80000250:	6d42                	ld	s10,16(sp)
    80000252:	6165                	addi	sp,sp,112
    80000254:	8082                	ret
      if(n < target){
    80000256:	0009871b          	sext.w	a4,s3
    8000025a:	fb677ce3          	bgeu	a4,s6,80000212 <consoleread+0xbc>
        cons.r--;
    8000025e:	00011717          	auipc	a4,0x11
    80000262:	faf72d23          	sw	a5,-70(a4) # 80011218 <cons+0x98>
    80000266:	b775                	j	80000212 <consoleread+0xbc>

0000000080000268 <consputc>:
{
    80000268:	1141                	addi	sp,sp,-16
    8000026a:	e406                	sd	ra,8(sp)
    8000026c:	e022                	sd	s0,0(sp)
    8000026e:	0800                	addi	s0,sp,16
  if(c == BACKSPACE){
    80000270:	10000793          	li	a5,256
    80000274:	00f50a63          	beq	a0,a5,80000288 <consputc+0x20>
    uartputc_sync(c);
    80000278:	00000097          	auipc	ra,0x0
    8000027c:	560080e7          	jalr	1376(ra) # 800007d8 <uartputc_sync>
}
    80000280:	60a2                	ld	ra,8(sp)
    80000282:	6402                	ld	s0,0(sp)
    80000284:	0141                	addi	sp,sp,16
    80000286:	8082                	ret
    uartputc_sync('\b'); uartputc_sync(' '); uartputc_sync('\b');
    80000288:	4521                	li	a0,8
    8000028a:	00000097          	auipc	ra,0x0
    8000028e:	54e080e7          	jalr	1358(ra) # 800007d8 <uartputc_sync>
    80000292:	02000513          	li	a0,32
    80000296:	00000097          	auipc	ra,0x0
    8000029a:	542080e7          	jalr	1346(ra) # 800007d8 <uartputc_sync>
    8000029e:	4521                	li	a0,8
    800002a0:	00000097          	auipc	ra,0x0
    800002a4:	538080e7          	jalr	1336(ra) # 800007d8 <uartputc_sync>
    800002a8:	bfe1                	j	80000280 <consputc+0x18>

00000000800002aa <consoleintr>:
// do erase/kill processing, append to cons.buf,
// wake up consoleread() if a whole line has arrived.
//
void
consoleintr(int c)
{
    800002aa:	1101                	addi	sp,sp,-32
    800002ac:	ec06                	sd	ra,24(sp)
    800002ae:	e822                	sd	s0,16(sp)
    800002b0:	e426                	sd	s1,8(sp)
    800002b2:	e04a                	sd	s2,0(sp)
    800002b4:	1000                	addi	s0,sp,32
    800002b6:	84aa                	mv	s1,a0
  acquire(&cons.lock);
    800002b8:	00011517          	auipc	a0,0x11
    800002bc:	ec850513          	addi	a0,a0,-312 # 80011180 <cons>
    800002c0:	00001097          	auipc	ra,0x1
    800002c4:	902080e7          	jalr	-1790(ra) # 80000bc2 <acquire>

  switch(c){
    800002c8:	47d5                	li	a5,21
    800002ca:	0af48663          	beq	s1,a5,80000376 <consoleintr+0xcc>
    800002ce:	0297ca63          	blt	a5,s1,80000302 <consoleintr+0x58>
    800002d2:	47a1                	li	a5,8
    800002d4:	0ef48763          	beq	s1,a5,800003c2 <consoleintr+0x118>
    800002d8:	47c1                	li	a5,16
    800002da:	10f49a63          	bne	s1,a5,800003ee <consoleintr+0x144>
  case C('P'):  // Print process list.
    procdump();
    800002de:	00002097          	auipc	ra,0x2
    800002e2:	1ea080e7          	jalr	490(ra) # 800024c8 <procdump>
      }
    }
    break;
  }
  
  release(&cons.lock);
    800002e6:	00011517          	auipc	a0,0x11
    800002ea:	e9a50513          	addi	a0,a0,-358 # 80011180 <cons>
    800002ee:	00001097          	auipc	ra,0x1
    800002f2:	988080e7          	jalr	-1656(ra) # 80000c76 <release>
}
    800002f6:	60e2                	ld	ra,24(sp)
    800002f8:	6442                	ld	s0,16(sp)
    800002fa:	64a2                	ld	s1,8(sp)
    800002fc:	6902                	ld	s2,0(sp)
    800002fe:	6105                	addi	sp,sp,32
    80000300:	8082                	ret
  switch(c){
    80000302:	07f00793          	li	a5,127
    80000306:	0af48e63          	beq	s1,a5,800003c2 <consoleintr+0x118>
    if(c != 0 && cons.e-cons.r < INPUT_BUF){
    8000030a:	00011717          	auipc	a4,0x11
    8000030e:	e7670713          	addi	a4,a4,-394 # 80011180 <cons>
    80000312:	0a072783          	lw	a5,160(a4)
    80000316:	09872703          	lw	a4,152(a4)
    8000031a:	9f99                	subw	a5,a5,a4
    8000031c:	07f00713          	li	a4,127
    80000320:	fcf763e3          	bltu	a4,a5,800002e6 <consoleintr+0x3c>
      c = (c == '\r') ? '\n' : c;
    80000324:	47b5                	li	a5,13
    80000326:	0cf48763          	beq	s1,a5,800003f4 <consoleintr+0x14a>
      consputc(c);
    8000032a:	8526                	mv	a0,s1
    8000032c:	00000097          	auipc	ra,0x0
    80000330:	f3c080e7          	jalr	-196(ra) # 80000268 <consputc>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    80000334:	00011797          	auipc	a5,0x11
    80000338:	e4c78793          	addi	a5,a5,-436 # 80011180 <cons>
    8000033c:	0a07a703          	lw	a4,160(a5)
    80000340:	0017069b          	addiw	a3,a4,1
    80000344:	0006861b          	sext.w	a2,a3
    80000348:	0ad7a023          	sw	a3,160(a5)
    8000034c:	07f77713          	andi	a4,a4,127
    80000350:	97ba                	add	a5,a5,a4
    80000352:	00978c23          	sb	s1,24(a5)
      if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF){
    80000356:	47a9                	li	a5,10
    80000358:	0cf48563          	beq	s1,a5,80000422 <consoleintr+0x178>
    8000035c:	4791                	li	a5,4
    8000035e:	0cf48263          	beq	s1,a5,80000422 <consoleintr+0x178>
    80000362:	00011797          	auipc	a5,0x11
    80000366:	eb67a783          	lw	a5,-330(a5) # 80011218 <cons+0x98>
    8000036a:	0807879b          	addiw	a5,a5,128
    8000036e:	f6f61ce3          	bne	a2,a5,800002e6 <consoleintr+0x3c>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    80000372:	863e                	mv	a2,a5
    80000374:	a07d                	j	80000422 <consoleintr+0x178>
    while(cons.e != cons.w &&
    80000376:	00011717          	auipc	a4,0x11
    8000037a:	e0a70713          	addi	a4,a4,-502 # 80011180 <cons>
    8000037e:	0a072783          	lw	a5,160(a4)
    80000382:	09c72703          	lw	a4,156(a4)
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    80000386:	00011497          	auipc	s1,0x11
    8000038a:	dfa48493          	addi	s1,s1,-518 # 80011180 <cons>
    while(cons.e != cons.w &&
    8000038e:	4929                	li	s2,10
    80000390:	f4f70be3          	beq	a4,a5,800002e6 <consoleintr+0x3c>
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    80000394:	37fd                	addiw	a5,a5,-1
    80000396:	07f7f713          	andi	a4,a5,127
    8000039a:	9726                	add	a4,a4,s1
    while(cons.e != cons.w &&
    8000039c:	01874703          	lbu	a4,24(a4)
    800003a0:	f52703e3          	beq	a4,s2,800002e6 <consoleintr+0x3c>
      cons.e--;
    800003a4:	0af4a023          	sw	a5,160(s1)
      consputc(BACKSPACE);
    800003a8:	10000513          	li	a0,256
    800003ac:	00000097          	auipc	ra,0x0
    800003b0:	ebc080e7          	jalr	-324(ra) # 80000268 <consputc>
    while(cons.e != cons.w &&
    800003b4:	0a04a783          	lw	a5,160(s1)
    800003b8:	09c4a703          	lw	a4,156(s1)
    800003bc:	fcf71ce3          	bne	a4,a5,80000394 <consoleintr+0xea>
    800003c0:	b71d                	j	800002e6 <consoleintr+0x3c>
    if(cons.e != cons.w){
    800003c2:	00011717          	auipc	a4,0x11
    800003c6:	dbe70713          	addi	a4,a4,-578 # 80011180 <cons>
    800003ca:	0a072783          	lw	a5,160(a4)
    800003ce:	09c72703          	lw	a4,156(a4)
    800003d2:	f0f70ae3          	beq	a4,a5,800002e6 <consoleintr+0x3c>
      cons.e--;
    800003d6:	37fd                	addiw	a5,a5,-1
    800003d8:	00011717          	auipc	a4,0x11
    800003dc:	e4f72423          	sw	a5,-440(a4) # 80011220 <cons+0xa0>
      consputc(BACKSPACE);
    800003e0:	10000513          	li	a0,256
    800003e4:	00000097          	auipc	ra,0x0
    800003e8:	e84080e7          	jalr	-380(ra) # 80000268 <consputc>
    800003ec:	bded                	j	800002e6 <consoleintr+0x3c>
    if(c != 0 && cons.e-cons.r < INPUT_BUF){
    800003ee:	ee048ce3          	beqz	s1,800002e6 <consoleintr+0x3c>
    800003f2:	bf21                	j	8000030a <consoleintr+0x60>
      consputc(c);
    800003f4:	4529                	li	a0,10
    800003f6:	00000097          	auipc	ra,0x0
    800003fa:	e72080e7          	jalr	-398(ra) # 80000268 <consputc>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    800003fe:	00011797          	auipc	a5,0x11
    80000402:	d8278793          	addi	a5,a5,-638 # 80011180 <cons>
    80000406:	0a07a703          	lw	a4,160(a5)
    8000040a:	0017069b          	addiw	a3,a4,1
    8000040e:	0006861b          	sext.w	a2,a3
    80000412:	0ad7a023          	sw	a3,160(a5)
    80000416:	07f77713          	andi	a4,a4,127
    8000041a:	97ba                	add	a5,a5,a4
    8000041c:	4729                	li	a4,10
    8000041e:	00e78c23          	sb	a4,24(a5)
        cons.w = cons.e;
    80000422:	00011797          	auipc	a5,0x11
    80000426:	dec7ad23          	sw	a2,-518(a5) # 8001121c <cons+0x9c>
        wakeup(&cons.r);
    8000042a:	00011517          	auipc	a0,0x11
    8000042e:	dee50513          	addi	a0,a0,-530 # 80011218 <cons+0x98>
    80000432:	00002097          	auipc	ra,0x2
    80000436:	f10080e7          	jalr	-240(ra) # 80002342 <wakeup>
    8000043a:	b575                	j	800002e6 <consoleintr+0x3c>

000000008000043c <consoleinit>:

void
consoleinit(void)
{
    8000043c:	1141                	addi	sp,sp,-16
    8000043e:	e406                	sd	ra,8(sp)
    80000440:	e022                	sd	s0,0(sp)
    80000442:	0800                	addi	s0,sp,16
  initlock(&cons.lock, "cons");
    80000444:	00008597          	auipc	a1,0x8
    80000448:	bcc58593          	addi	a1,a1,-1076 # 80008010 <etext+0x10>
    8000044c:	00011517          	auipc	a0,0x11
    80000450:	d3450513          	addi	a0,a0,-716 # 80011180 <cons>
    80000454:	00000097          	auipc	ra,0x0
    80000458:	6de080e7          	jalr	1758(ra) # 80000b32 <initlock>

  uartinit();
    8000045c:	00000097          	auipc	ra,0x0
    80000460:	32c080e7          	jalr	812(ra) # 80000788 <uartinit>

  // connect read and write system calls
  // to consoleread and consolewrite.
  devsw[CONSOLE].read = consoleread;
    80000464:	0001c797          	auipc	a5,0x1c
    80000468:	2ac78793          	addi	a5,a5,684 # 8001c710 <devsw>
    8000046c:	00000717          	auipc	a4,0x0
    80000470:	cea70713          	addi	a4,a4,-790 # 80000156 <consoleread>
    80000474:	eb98                	sd	a4,16(a5)
  devsw[CONSOLE].write = consolewrite;
    80000476:	00000717          	auipc	a4,0x0
    8000047a:	c7c70713          	addi	a4,a4,-900 # 800000f2 <consolewrite>
    8000047e:	ef98                	sd	a4,24(a5)
}
    80000480:	60a2                	ld	ra,8(sp)
    80000482:	6402                	ld	s0,0(sp)
    80000484:	0141                	addi	sp,sp,16
    80000486:	8082                	ret

0000000080000488 <printint>:

static char digits[] = "0123456789abcdef";

static void
printint(int xx, int base, int sign)
{
    80000488:	7179                	addi	sp,sp,-48
    8000048a:	f406                	sd	ra,40(sp)
    8000048c:	f022                	sd	s0,32(sp)
    8000048e:	ec26                	sd	s1,24(sp)
    80000490:	e84a                	sd	s2,16(sp)
    80000492:	1800                	addi	s0,sp,48
  char buf[16];
  int i;
  uint x;

  if(sign && (sign = xx < 0))
    80000494:	c219                	beqz	a2,8000049a <printint+0x12>
    80000496:	08054763          	bltz	a0,80000524 <printint+0x9c>
    x = -xx;
  else
    x = xx;
    8000049a:	2501                	sext.w	a0,a0
    8000049c:	4881                	li	a7,0
    8000049e:	fd040693          	addi	a3,s0,-48

  i = 0;
    800004a2:	4701                	li	a4,0
  do {
    buf[i++] = digits[x % base];
    800004a4:	2581                	sext.w	a1,a1
    800004a6:	00008617          	auipc	a2,0x8
    800004aa:	b9a60613          	addi	a2,a2,-1126 # 80008040 <digits>
    800004ae:	883a                	mv	a6,a4
    800004b0:	2705                	addiw	a4,a4,1
    800004b2:	02b577bb          	remuw	a5,a0,a1
    800004b6:	1782                	slli	a5,a5,0x20
    800004b8:	9381                	srli	a5,a5,0x20
    800004ba:	97b2                	add	a5,a5,a2
    800004bc:	0007c783          	lbu	a5,0(a5)
    800004c0:	00f68023          	sb	a5,0(a3)
  } while((x /= base) != 0);
    800004c4:	0005079b          	sext.w	a5,a0
    800004c8:	02b5553b          	divuw	a0,a0,a1
    800004cc:	0685                	addi	a3,a3,1
    800004ce:	feb7f0e3          	bgeu	a5,a1,800004ae <printint+0x26>

  if(sign)
    800004d2:	00088c63          	beqz	a7,800004ea <printint+0x62>
    buf[i++] = '-';
    800004d6:	fe070793          	addi	a5,a4,-32
    800004da:	00878733          	add	a4,a5,s0
    800004de:	02d00793          	li	a5,45
    800004e2:	fef70823          	sb	a5,-16(a4)
    800004e6:	0028071b          	addiw	a4,a6,2

  while(--i >= 0)
    800004ea:	02e05763          	blez	a4,80000518 <printint+0x90>
    800004ee:	fd040793          	addi	a5,s0,-48
    800004f2:	00e784b3          	add	s1,a5,a4
    800004f6:	fff78913          	addi	s2,a5,-1
    800004fa:	993a                	add	s2,s2,a4
    800004fc:	377d                	addiw	a4,a4,-1
    800004fe:	1702                	slli	a4,a4,0x20
    80000500:	9301                	srli	a4,a4,0x20
    80000502:	40e90933          	sub	s2,s2,a4
    consputc(buf[i]);
    80000506:	fff4c503          	lbu	a0,-1(s1)
    8000050a:	00000097          	auipc	ra,0x0
    8000050e:	d5e080e7          	jalr	-674(ra) # 80000268 <consputc>
  while(--i >= 0)
    80000512:	14fd                	addi	s1,s1,-1
    80000514:	ff2499e3          	bne	s1,s2,80000506 <printint+0x7e>
}
    80000518:	70a2                	ld	ra,40(sp)
    8000051a:	7402                	ld	s0,32(sp)
    8000051c:	64e2                	ld	s1,24(sp)
    8000051e:	6942                	ld	s2,16(sp)
    80000520:	6145                	addi	sp,sp,48
    80000522:	8082                	ret
    x = -xx;
    80000524:	40a0053b          	negw	a0,a0
  if(sign && (sign = xx < 0))
    80000528:	4885                	li	a7,1
    x = -xx;
    8000052a:	bf95                	j	8000049e <printint+0x16>

000000008000052c <panic>:
    release(&pr.lock);
}

void
panic(char *s)
{
    8000052c:	1101                	addi	sp,sp,-32
    8000052e:	ec06                	sd	ra,24(sp)
    80000530:	e822                	sd	s0,16(sp)
    80000532:	e426                	sd	s1,8(sp)
    80000534:	1000                	addi	s0,sp,32
    80000536:	84aa                	mv	s1,a0
  pr.locking = 0;
    80000538:	00011797          	auipc	a5,0x11
    8000053c:	d007a423          	sw	zero,-760(a5) # 80011240 <pr+0x18>
  printf("panic: ");
    80000540:	00008517          	auipc	a0,0x8
    80000544:	ad850513          	addi	a0,a0,-1320 # 80008018 <etext+0x18>
    80000548:	00000097          	auipc	ra,0x0
    8000054c:	02e080e7          	jalr	46(ra) # 80000576 <printf>
  printf(s);
    80000550:	8526                	mv	a0,s1
    80000552:	00000097          	auipc	ra,0x0
    80000556:	024080e7          	jalr	36(ra) # 80000576 <printf>
  printf("\n");
    8000055a:	00008517          	auipc	a0,0x8
    8000055e:	b6e50513          	addi	a0,a0,-1170 # 800080c8 <digits+0x88>
    80000562:	00000097          	auipc	ra,0x0
    80000566:	014080e7          	jalr	20(ra) # 80000576 <printf>
  panicked = 1; // freeze uart output from other CPUs
    8000056a:	4785                	li	a5,1
    8000056c:	00009717          	auipc	a4,0x9
    80000570:	a8f72a23          	sw	a5,-1388(a4) # 80009000 <panicked>
  for(;;)
    80000574:	a001                	j	80000574 <panic+0x48>

0000000080000576 <printf>:
{
    80000576:	7131                	addi	sp,sp,-192
    80000578:	fc86                	sd	ra,120(sp)
    8000057a:	f8a2                	sd	s0,112(sp)
    8000057c:	f4a6                	sd	s1,104(sp)
    8000057e:	f0ca                	sd	s2,96(sp)
    80000580:	ecce                	sd	s3,88(sp)
    80000582:	e8d2                	sd	s4,80(sp)
    80000584:	e4d6                	sd	s5,72(sp)
    80000586:	e0da                	sd	s6,64(sp)
    80000588:	fc5e                	sd	s7,56(sp)
    8000058a:	f862                	sd	s8,48(sp)
    8000058c:	f466                	sd	s9,40(sp)
    8000058e:	f06a                	sd	s10,32(sp)
    80000590:	ec6e                	sd	s11,24(sp)
    80000592:	0100                	addi	s0,sp,128
    80000594:	8a2a                	mv	s4,a0
    80000596:	e40c                	sd	a1,8(s0)
    80000598:	e810                	sd	a2,16(s0)
    8000059a:	ec14                	sd	a3,24(s0)
    8000059c:	f018                	sd	a4,32(s0)
    8000059e:	f41c                	sd	a5,40(s0)
    800005a0:	03043823          	sd	a6,48(s0)
    800005a4:	03143c23          	sd	a7,56(s0)
  locking = pr.locking;
    800005a8:	00011d97          	auipc	s11,0x11
    800005ac:	c98dad83          	lw	s11,-872(s11) # 80011240 <pr+0x18>
  if(locking)
    800005b0:	020d9b63          	bnez	s11,800005e6 <printf+0x70>
  if (fmt == 0)
    800005b4:	040a0263          	beqz	s4,800005f8 <printf+0x82>
  va_start(ap, fmt);
    800005b8:	00840793          	addi	a5,s0,8
    800005bc:	f8f43423          	sd	a5,-120(s0)
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    800005c0:	000a4503          	lbu	a0,0(s4)
    800005c4:	14050f63          	beqz	a0,80000722 <printf+0x1ac>
    800005c8:	4981                	li	s3,0
    if(c != '%'){
    800005ca:	02500a93          	li	s5,37
    switch(c){
    800005ce:	07000b93          	li	s7,112
  consputc('x');
    800005d2:	4d41                	li	s10,16
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    800005d4:	00008b17          	auipc	s6,0x8
    800005d8:	a6cb0b13          	addi	s6,s6,-1428 # 80008040 <digits>
    switch(c){
    800005dc:	07300c93          	li	s9,115
    800005e0:	06400c13          	li	s8,100
    800005e4:	a82d                	j	8000061e <printf+0xa8>
    acquire(&pr.lock);
    800005e6:	00011517          	auipc	a0,0x11
    800005ea:	c4250513          	addi	a0,a0,-958 # 80011228 <pr>
    800005ee:	00000097          	auipc	ra,0x0
    800005f2:	5d4080e7          	jalr	1492(ra) # 80000bc2 <acquire>
    800005f6:	bf7d                	j	800005b4 <printf+0x3e>
    panic("null fmt");
    800005f8:	00008517          	auipc	a0,0x8
    800005fc:	a3050513          	addi	a0,a0,-1488 # 80008028 <etext+0x28>
    80000600:	00000097          	auipc	ra,0x0
    80000604:	f2c080e7          	jalr	-212(ra) # 8000052c <panic>
      consputc(c);
    80000608:	00000097          	auipc	ra,0x0
    8000060c:	c60080e7          	jalr	-928(ra) # 80000268 <consputc>
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    80000610:	2985                	addiw	s3,s3,1
    80000612:	013a07b3          	add	a5,s4,s3
    80000616:	0007c503          	lbu	a0,0(a5)
    8000061a:	10050463          	beqz	a0,80000722 <printf+0x1ac>
    if(c != '%'){
    8000061e:	ff5515e3          	bne	a0,s5,80000608 <printf+0x92>
    c = fmt[++i] & 0xff;
    80000622:	2985                	addiw	s3,s3,1
    80000624:	013a07b3          	add	a5,s4,s3
    80000628:	0007c783          	lbu	a5,0(a5)
    8000062c:	0007849b          	sext.w	s1,a5
    if(c == 0)
    80000630:	cbed                	beqz	a5,80000722 <printf+0x1ac>
    switch(c){
    80000632:	05778a63          	beq	a5,s7,80000686 <printf+0x110>
    80000636:	02fbf663          	bgeu	s7,a5,80000662 <printf+0xec>
    8000063a:	09978863          	beq	a5,s9,800006ca <printf+0x154>
    8000063e:	07800713          	li	a4,120
    80000642:	0ce79563          	bne	a5,a4,8000070c <printf+0x196>
      printint(va_arg(ap, int), 16, 1);
    80000646:	f8843783          	ld	a5,-120(s0)
    8000064a:	00878713          	addi	a4,a5,8
    8000064e:	f8e43423          	sd	a4,-120(s0)
    80000652:	4605                	li	a2,1
    80000654:	85ea                	mv	a1,s10
    80000656:	4388                	lw	a0,0(a5)
    80000658:	00000097          	auipc	ra,0x0
    8000065c:	e30080e7          	jalr	-464(ra) # 80000488 <printint>
      break;
    80000660:	bf45                	j	80000610 <printf+0x9a>
    switch(c){
    80000662:	09578f63          	beq	a5,s5,80000700 <printf+0x18a>
    80000666:	0b879363          	bne	a5,s8,8000070c <printf+0x196>
      printint(va_arg(ap, int), 10, 1);
    8000066a:	f8843783          	ld	a5,-120(s0)
    8000066e:	00878713          	addi	a4,a5,8
    80000672:	f8e43423          	sd	a4,-120(s0)
    80000676:	4605                	li	a2,1
    80000678:	45a9                	li	a1,10
    8000067a:	4388                	lw	a0,0(a5)
    8000067c:	00000097          	auipc	ra,0x0
    80000680:	e0c080e7          	jalr	-500(ra) # 80000488 <printint>
      break;
    80000684:	b771                	j	80000610 <printf+0x9a>
      printptr(va_arg(ap, uint64));
    80000686:	f8843783          	ld	a5,-120(s0)
    8000068a:	00878713          	addi	a4,a5,8
    8000068e:	f8e43423          	sd	a4,-120(s0)
    80000692:	0007b903          	ld	s2,0(a5)
  consputc('0');
    80000696:	03000513          	li	a0,48
    8000069a:	00000097          	auipc	ra,0x0
    8000069e:	bce080e7          	jalr	-1074(ra) # 80000268 <consputc>
  consputc('x');
    800006a2:	07800513          	li	a0,120
    800006a6:	00000097          	auipc	ra,0x0
    800006aa:	bc2080e7          	jalr	-1086(ra) # 80000268 <consputc>
    800006ae:	84ea                	mv	s1,s10
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    800006b0:	03c95793          	srli	a5,s2,0x3c
    800006b4:	97da                	add	a5,a5,s6
    800006b6:	0007c503          	lbu	a0,0(a5)
    800006ba:	00000097          	auipc	ra,0x0
    800006be:	bae080e7          	jalr	-1106(ra) # 80000268 <consputc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
    800006c2:	0912                	slli	s2,s2,0x4
    800006c4:	34fd                	addiw	s1,s1,-1
    800006c6:	f4ed                	bnez	s1,800006b0 <printf+0x13a>
    800006c8:	b7a1                	j	80000610 <printf+0x9a>
      if((s = va_arg(ap, char*)) == 0)
    800006ca:	f8843783          	ld	a5,-120(s0)
    800006ce:	00878713          	addi	a4,a5,8
    800006d2:	f8e43423          	sd	a4,-120(s0)
    800006d6:	6384                	ld	s1,0(a5)
    800006d8:	cc89                	beqz	s1,800006f2 <printf+0x17c>
      for(; *s; s++)
    800006da:	0004c503          	lbu	a0,0(s1)
    800006de:	d90d                	beqz	a0,80000610 <printf+0x9a>
        consputc(*s);
    800006e0:	00000097          	auipc	ra,0x0
    800006e4:	b88080e7          	jalr	-1144(ra) # 80000268 <consputc>
      for(; *s; s++)
    800006e8:	0485                	addi	s1,s1,1
    800006ea:	0004c503          	lbu	a0,0(s1)
    800006ee:	f96d                	bnez	a0,800006e0 <printf+0x16a>
    800006f0:	b705                	j	80000610 <printf+0x9a>
        s = "(null)";
    800006f2:	00008497          	auipc	s1,0x8
    800006f6:	92e48493          	addi	s1,s1,-1746 # 80008020 <etext+0x20>
      for(; *s; s++)
    800006fa:	02800513          	li	a0,40
    800006fe:	b7cd                	j	800006e0 <printf+0x16a>
      consputc('%');
    80000700:	8556                	mv	a0,s5
    80000702:	00000097          	auipc	ra,0x0
    80000706:	b66080e7          	jalr	-1178(ra) # 80000268 <consputc>
      break;
    8000070a:	b719                	j	80000610 <printf+0x9a>
      consputc('%');
    8000070c:	8556                	mv	a0,s5
    8000070e:	00000097          	auipc	ra,0x0
    80000712:	b5a080e7          	jalr	-1190(ra) # 80000268 <consputc>
      consputc(c);
    80000716:	8526                	mv	a0,s1
    80000718:	00000097          	auipc	ra,0x0
    8000071c:	b50080e7          	jalr	-1200(ra) # 80000268 <consputc>
      break;
    80000720:	bdc5                	j	80000610 <printf+0x9a>
  if(locking)
    80000722:	020d9163          	bnez	s11,80000744 <printf+0x1ce>
}
    80000726:	70e6                	ld	ra,120(sp)
    80000728:	7446                	ld	s0,112(sp)
    8000072a:	74a6                	ld	s1,104(sp)
    8000072c:	7906                	ld	s2,96(sp)
    8000072e:	69e6                	ld	s3,88(sp)
    80000730:	6a46                	ld	s4,80(sp)
    80000732:	6aa6                	ld	s5,72(sp)
    80000734:	6b06                	ld	s6,64(sp)
    80000736:	7be2                	ld	s7,56(sp)
    80000738:	7c42                	ld	s8,48(sp)
    8000073a:	7ca2                	ld	s9,40(sp)
    8000073c:	7d02                	ld	s10,32(sp)
    8000073e:	6de2                	ld	s11,24(sp)
    80000740:	6129                	addi	sp,sp,192
    80000742:	8082                	ret
    release(&pr.lock);
    80000744:	00011517          	auipc	a0,0x11
    80000748:	ae450513          	addi	a0,a0,-1308 # 80011228 <pr>
    8000074c:	00000097          	auipc	ra,0x0
    80000750:	52a080e7          	jalr	1322(ra) # 80000c76 <release>
}
    80000754:	bfc9                	j	80000726 <printf+0x1b0>

0000000080000756 <printfinit>:
    ;
}

void
printfinit(void)
{
    80000756:	1101                	addi	sp,sp,-32
    80000758:	ec06                	sd	ra,24(sp)
    8000075a:	e822                	sd	s0,16(sp)
    8000075c:	e426                	sd	s1,8(sp)
    8000075e:	1000                	addi	s0,sp,32
  initlock(&pr.lock, "pr");
    80000760:	00011497          	auipc	s1,0x11
    80000764:	ac848493          	addi	s1,s1,-1336 # 80011228 <pr>
    80000768:	00008597          	auipc	a1,0x8
    8000076c:	8d058593          	addi	a1,a1,-1840 # 80008038 <etext+0x38>
    80000770:	8526                	mv	a0,s1
    80000772:	00000097          	auipc	ra,0x0
    80000776:	3c0080e7          	jalr	960(ra) # 80000b32 <initlock>
  pr.locking = 1;
    8000077a:	4785                	li	a5,1
    8000077c:	cc9c                	sw	a5,24(s1)
}
    8000077e:	60e2                	ld	ra,24(sp)
    80000780:	6442                	ld	s0,16(sp)
    80000782:	64a2                	ld	s1,8(sp)
    80000784:	6105                	addi	sp,sp,32
    80000786:	8082                	ret

0000000080000788 <uartinit>:

void uartstart();

void
uartinit(void)
{
    80000788:	1141                	addi	sp,sp,-16
    8000078a:	e406                	sd	ra,8(sp)
    8000078c:	e022                	sd	s0,0(sp)
    8000078e:	0800                	addi	s0,sp,16
  // disable interrupts.
  WriteReg(IER, 0x00);
    80000790:	100007b7          	lui	a5,0x10000
    80000794:	000780a3          	sb	zero,1(a5) # 10000001 <_entry-0x6fffffff>

  // special mode to set baud rate.
  WriteReg(LCR, LCR_BAUD_LATCH);
    80000798:	f8000713          	li	a4,-128
    8000079c:	00e781a3          	sb	a4,3(a5)

  // LSB for baud rate of 38.4K.
  WriteReg(0, 0x03);
    800007a0:	470d                	li	a4,3
    800007a2:	00e78023          	sb	a4,0(a5)

  // MSB for baud rate of 38.4K.
  WriteReg(1, 0x00);
    800007a6:	000780a3          	sb	zero,1(a5)

  // leave set-baud mode,
  // and set word length to 8 bits, no parity.
  WriteReg(LCR, LCR_EIGHT_BITS);
    800007aa:	00e781a3          	sb	a4,3(a5)

  // reset and enable FIFOs.
  WriteReg(FCR, FCR_FIFO_ENABLE | FCR_FIFO_CLEAR);
    800007ae:	469d                	li	a3,7
    800007b0:	00d78123          	sb	a3,2(a5)

  // enable transmit and receive interrupts.
  WriteReg(IER, IER_TX_ENABLE | IER_RX_ENABLE);
    800007b4:	00e780a3          	sb	a4,1(a5)

  initlock(&uart_tx_lock, "uart");
    800007b8:	00008597          	auipc	a1,0x8
    800007bc:	8a058593          	addi	a1,a1,-1888 # 80008058 <digits+0x18>
    800007c0:	00011517          	auipc	a0,0x11
    800007c4:	a8850513          	addi	a0,a0,-1400 # 80011248 <uart_tx_lock>
    800007c8:	00000097          	auipc	ra,0x0
    800007cc:	36a080e7          	jalr	874(ra) # 80000b32 <initlock>
}
    800007d0:	60a2                	ld	ra,8(sp)
    800007d2:	6402                	ld	s0,0(sp)
    800007d4:	0141                	addi	sp,sp,16
    800007d6:	8082                	ret

00000000800007d8 <uartputc_sync>:
// use interrupts, for use by kernel printf() and
// to echo characters. it spins waiting for the uart's
// output register to be empty.
void
uartputc_sync(int c)
{
    800007d8:	1101                	addi	sp,sp,-32
    800007da:	ec06                	sd	ra,24(sp)
    800007dc:	e822                	sd	s0,16(sp)
    800007de:	e426                	sd	s1,8(sp)
    800007e0:	1000                	addi	s0,sp,32
    800007e2:	84aa                	mv	s1,a0
  push_off();
    800007e4:	00000097          	auipc	ra,0x0
    800007e8:	392080e7          	jalr	914(ra) # 80000b76 <push_off>

  if(panicked){
    800007ec:	00009797          	auipc	a5,0x9
    800007f0:	8147a783          	lw	a5,-2028(a5) # 80009000 <panicked>
    for(;;)
      ;
  }

  // wait for Transmit Holding Empty to be set in LSR.
  while((ReadReg(LSR) & LSR_TX_IDLE) == 0)
    800007f4:	10000737          	lui	a4,0x10000
  if(panicked){
    800007f8:	c391                	beqz	a5,800007fc <uartputc_sync+0x24>
    for(;;)
    800007fa:	a001                	j	800007fa <uartputc_sync+0x22>
  while((ReadReg(LSR) & LSR_TX_IDLE) == 0)
    800007fc:	00574783          	lbu	a5,5(a4) # 10000005 <_entry-0x6ffffffb>
    80000800:	0207f793          	andi	a5,a5,32
    80000804:	dfe5                	beqz	a5,800007fc <uartputc_sync+0x24>
    ;
  WriteReg(THR, c);
    80000806:	0ff4f513          	zext.b	a0,s1
    8000080a:	100007b7          	lui	a5,0x10000
    8000080e:	00a78023          	sb	a0,0(a5) # 10000000 <_entry-0x70000000>

  pop_off();
    80000812:	00000097          	auipc	ra,0x0
    80000816:	404080e7          	jalr	1028(ra) # 80000c16 <pop_off>
}
    8000081a:	60e2                	ld	ra,24(sp)
    8000081c:	6442                	ld	s0,16(sp)
    8000081e:	64a2                	ld	s1,8(sp)
    80000820:	6105                	addi	sp,sp,32
    80000822:	8082                	ret

0000000080000824 <uartstart>:
// called from both the top- and bottom-half.
void
uartstart()
{
  while(1){
    if(uart_tx_w == uart_tx_r){
    80000824:	00008797          	auipc	a5,0x8
    80000828:	7e47b783          	ld	a5,2020(a5) # 80009008 <uart_tx_r>
    8000082c:	00008717          	auipc	a4,0x8
    80000830:	7e473703          	ld	a4,2020(a4) # 80009010 <uart_tx_w>
    80000834:	06f70a63          	beq	a4,a5,800008a8 <uartstart+0x84>
{
    80000838:	7139                	addi	sp,sp,-64
    8000083a:	fc06                	sd	ra,56(sp)
    8000083c:	f822                	sd	s0,48(sp)
    8000083e:	f426                	sd	s1,40(sp)
    80000840:	f04a                	sd	s2,32(sp)
    80000842:	ec4e                	sd	s3,24(sp)
    80000844:	e852                	sd	s4,16(sp)
    80000846:	e456                	sd	s5,8(sp)
    80000848:	0080                	addi	s0,sp,64
      // transmit buffer is empty.
      return;
    }
    
    if((ReadReg(LSR) & LSR_TX_IDLE) == 0){
    8000084a:	10000937          	lui	s2,0x10000
      // so we cannot give it another byte.
      // it will interrupt when it's ready for a new byte.
      return;
    }
    
    int c = uart_tx_buf[uart_tx_r % UART_TX_BUF_SIZE];
    8000084e:	00011a17          	auipc	s4,0x11
    80000852:	9faa0a13          	addi	s4,s4,-1542 # 80011248 <uart_tx_lock>
    uart_tx_r += 1;
    80000856:	00008497          	auipc	s1,0x8
    8000085a:	7b248493          	addi	s1,s1,1970 # 80009008 <uart_tx_r>
    if(uart_tx_w == uart_tx_r){
    8000085e:	00008997          	auipc	s3,0x8
    80000862:	7b298993          	addi	s3,s3,1970 # 80009010 <uart_tx_w>
    if((ReadReg(LSR) & LSR_TX_IDLE) == 0){
    80000866:	00594703          	lbu	a4,5(s2) # 10000005 <_entry-0x6ffffffb>
    8000086a:	02077713          	andi	a4,a4,32
    8000086e:	c705                	beqz	a4,80000896 <uartstart+0x72>
    int c = uart_tx_buf[uart_tx_r % UART_TX_BUF_SIZE];
    80000870:	01f7f713          	andi	a4,a5,31
    80000874:	9752                	add	a4,a4,s4
    80000876:	01874a83          	lbu	s5,24(a4)
    uart_tx_r += 1;
    8000087a:	0785                	addi	a5,a5,1
    8000087c:	e09c                	sd	a5,0(s1)
    
    // maybe uartputc() is waiting for space in the buffer.
    wakeup(&uart_tx_r);
    8000087e:	8526                	mv	a0,s1
    80000880:	00002097          	auipc	ra,0x2
    80000884:	ac2080e7          	jalr	-1342(ra) # 80002342 <wakeup>
    
    WriteReg(THR, c);
    80000888:	01590023          	sb	s5,0(s2)
    if(uart_tx_w == uart_tx_r){
    8000088c:	609c                	ld	a5,0(s1)
    8000088e:	0009b703          	ld	a4,0(s3)
    80000892:	fcf71ae3          	bne	a4,a5,80000866 <uartstart+0x42>
  }
}
    80000896:	70e2                	ld	ra,56(sp)
    80000898:	7442                	ld	s0,48(sp)
    8000089a:	74a2                	ld	s1,40(sp)
    8000089c:	7902                	ld	s2,32(sp)
    8000089e:	69e2                	ld	s3,24(sp)
    800008a0:	6a42                	ld	s4,16(sp)
    800008a2:	6aa2                	ld	s5,8(sp)
    800008a4:	6121                	addi	sp,sp,64
    800008a6:	8082                	ret
    800008a8:	8082                	ret

00000000800008aa <uartputc>:
{
    800008aa:	7179                	addi	sp,sp,-48
    800008ac:	f406                	sd	ra,40(sp)
    800008ae:	f022                	sd	s0,32(sp)
    800008b0:	ec26                	sd	s1,24(sp)
    800008b2:	e84a                	sd	s2,16(sp)
    800008b4:	e44e                	sd	s3,8(sp)
    800008b6:	e052                	sd	s4,0(sp)
    800008b8:	1800                	addi	s0,sp,48
    800008ba:	8a2a                	mv	s4,a0
  acquire(&uart_tx_lock);
    800008bc:	00011517          	auipc	a0,0x11
    800008c0:	98c50513          	addi	a0,a0,-1652 # 80011248 <uart_tx_lock>
    800008c4:	00000097          	auipc	ra,0x0
    800008c8:	2fe080e7          	jalr	766(ra) # 80000bc2 <acquire>
  if(panicked){
    800008cc:	00008797          	auipc	a5,0x8
    800008d0:	7347a783          	lw	a5,1844(a5) # 80009000 <panicked>
    800008d4:	c391                	beqz	a5,800008d8 <uartputc+0x2e>
    for(;;)
    800008d6:	a001                	j	800008d6 <uartputc+0x2c>
    if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
    800008d8:	00008717          	auipc	a4,0x8
    800008dc:	73873703          	ld	a4,1848(a4) # 80009010 <uart_tx_w>
    800008e0:	00008797          	auipc	a5,0x8
    800008e4:	7287b783          	ld	a5,1832(a5) # 80009008 <uart_tx_r>
    800008e8:	02078793          	addi	a5,a5,32
    800008ec:	02e79b63          	bne	a5,a4,80000922 <uartputc+0x78>
      sleep(&uart_tx_r, &uart_tx_lock);
    800008f0:	00011997          	auipc	s3,0x11
    800008f4:	95898993          	addi	s3,s3,-1704 # 80011248 <uart_tx_lock>
    800008f8:	00008497          	auipc	s1,0x8
    800008fc:	71048493          	addi	s1,s1,1808 # 80009008 <uart_tx_r>
    if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
    80000900:	00008917          	auipc	s2,0x8
    80000904:	71090913          	addi	s2,s2,1808 # 80009010 <uart_tx_w>
      sleep(&uart_tx_r, &uart_tx_lock);
    80000908:	85ce                	mv	a1,s3
    8000090a:	8526                	mv	a0,s1
    8000090c:	00002097          	auipc	ra,0x2
    80000910:	8b6080e7          	jalr	-1866(ra) # 800021c2 <sleep>
    if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
    80000914:	00093703          	ld	a4,0(s2)
    80000918:	609c                	ld	a5,0(s1)
    8000091a:	02078793          	addi	a5,a5,32
    8000091e:	fee785e3          	beq	a5,a4,80000908 <uartputc+0x5e>
      uart_tx_buf[uart_tx_w % UART_TX_BUF_SIZE] = c;
    80000922:	00011497          	auipc	s1,0x11
    80000926:	92648493          	addi	s1,s1,-1754 # 80011248 <uart_tx_lock>
    8000092a:	01f77793          	andi	a5,a4,31
    8000092e:	97a6                	add	a5,a5,s1
    80000930:	01478c23          	sb	s4,24(a5)
      uart_tx_w += 1;
    80000934:	0705                	addi	a4,a4,1
    80000936:	00008797          	auipc	a5,0x8
    8000093a:	6ce7bd23          	sd	a4,1754(a5) # 80009010 <uart_tx_w>
      uartstart();
    8000093e:	00000097          	auipc	ra,0x0
    80000942:	ee6080e7          	jalr	-282(ra) # 80000824 <uartstart>
      release(&uart_tx_lock);
    80000946:	8526                	mv	a0,s1
    80000948:	00000097          	auipc	ra,0x0
    8000094c:	32e080e7          	jalr	814(ra) # 80000c76 <release>
}
    80000950:	70a2                	ld	ra,40(sp)
    80000952:	7402                	ld	s0,32(sp)
    80000954:	64e2                	ld	s1,24(sp)
    80000956:	6942                	ld	s2,16(sp)
    80000958:	69a2                	ld	s3,8(sp)
    8000095a:	6a02                	ld	s4,0(sp)
    8000095c:	6145                	addi	sp,sp,48
    8000095e:	8082                	ret

0000000080000960 <uartgetc>:

// read one input character from the UART.
// return -1 if none is waiting.
int
uartgetc(void)
{
    80000960:	1141                	addi	sp,sp,-16
    80000962:	e422                	sd	s0,8(sp)
    80000964:	0800                	addi	s0,sp,16
  if(ReadReg(LSR) & 0x01){
    80000966:	100007b7          	lui	a5,0x10000
    8000096a:	0057c783          	lbu	a5,5(a5) # 10000005 <_entry-0x6ffffffb>
    8000096e:	8b85                	andi	a5,a5,1
    80000970:	cb81                	beqz	a5,80000980 <uartgetc+0x20>
    // input data is ready.
    return ReadReg(RHR);
    80000972:	100007b7          	lui	a5,0x10000
    80000976:	0007c503          	lbu	a0,0(a5) # 10000000 <_entry-0x70000000>
  } else {
    return -1;
  }
}
    8000097a:	6422                	ld	s0,8(sp)
    8000097c:	0141                	addi	sp,sp,16
    8000097e:	8082                	ret
    return -1;
    80000980:	557d                	li	a0,-1
    80000982:	bfe5                	j	8000097a <uartgetc+0x1a>

0000000080000984 <uartintr>:
// handle a uart interrupt, raised because input has
// arrived, or the uart is ready for more output, or
// both. called from trap.c.
void
uartintr(void)
{
    80000984:	1101                	addi	sp,sp,-32
    80000986:	ec06                	sd	ra,24(sp)
    80000988:	e822                	sd	s0,16(sp)
    8000098a:	e426                	sd	s1,8(sp)
    8000098c:	1000                	addi	s0,sp,32
  // read and process incoming characters.
  while(1){
    int c = uartgetc();
    if(c == -1)
    8000098e:	54fd                	li	s1,-1
    80000990:	a029                	j	8000099a <uartintr+0x16>
      break;
    consoleintr(c);
    80000992:	00000097          	auipc	ra,0x0
    80000996:	918080e7          	jalr	-1768(ra) # 800002aa <consoleintr>
    int c = uartgetc();
    8000099a:	00000097          	auipc	ra,0x0
    8000099e:	fc6080e7          	jalr	-58(ra) # 80000960 <uartgetc>
    if(c == -1)
    800009a2:	fe9518e3          	bne	a0,s1,80000992 <uartintr+0xe>
  }

  // send buffered characters.
  acquire(&uart_tx_lock);
    800009a6:	00011497          	auipc	s1,0x11
    800009aa:	8a248493          	addi	s1,s1,-1886 # 80011248 <uart_tx_lock>
    800009ae:	8526                	mv	a0,s1
    800009b0:	00000097          	auipc	ra,0x0
    800009b4:	212080e7          	jalr	530(ra) # 80000bc2 <acquire>
  uartstart();
    800009b8:	00000097          	auipc	ra,0x0
    800009bc:	e6c080e7          	jalr	-404(ra) # 80000824 <uartstart>
  release(&uart_tx_lock);
    800009c0:	8526                	mv	a0,s1
    800009c2:	00000097          	auipc	ra,0x0
    800009c6:	2b4080e7          	jalr	692(ra) # 80000c76 <release>
}
    800009ca:	60e2                	ld	ra,24(sp)
    800009cc:	6442                	ld	s0,16(sp)
    800009ce:	64a2                	ld	s1,8(sp)
    800009d0:	6105                	addi	sp,sp,32
    800009d2:	8082                	ret

00000000800009d4 <kfree>:
// which normally should have been returned by a
// call to kalloc().  (The exception is when
// initializing the allocator; see kinit above.)
void
kfree(void *pa)
{
    800009d4:	1101                	addi	sp,sp,-32
    800009d6:	ec06                	sd	ra,24(sp)
    800009d8:	e822                	sd	s0,16(sp)
    800009da:	e426                	sd	s1,8(sp)
    800009dc:	e04a                	sd	s2,0(sp)
    800009de:	1000                	addi	s0,sp,32
  struct run *r;

  if(((uint64)pa % PGSIZE) != 0 || (char*)pa < end || (uint64)pa >= PHYSTOP)
    800009e0:	03451793          	slli	a5,a0,0x34
    800009e4:	ebb9                	bnez	a5,80000a3a <kfree+0x66>
    800009e6:	84aa                	mv	s1,a0
    800009e8:	00020797          	auipc	a5,0x20
    800009ec:	61878793          	addi	a5,a5,1560 # 80021000 <end>
    800009f0:	04f56563          	bltu	a0,a5,80000a3a <kfree+0x66>
    800009f4:	47c5                	li	a5,17
    800009f6:	07ee                	slli	a5,a5,0x1b
    800009f8:	04f57163          	bgeu	a0,a5,80000a3a <kfree+0x66>
    panic("kfree");

  // Fill with junk to catch dangling refs.
  memset(pa, 1, PGSIZE);
    800009fc:	6605                	lui	a2,0x1
    800009fe:	4585                	li	a1,1
    80000a00:	00000097          	auipc	ra,0x0
    80000a04:	2be080e7          	jalr	702(ra) # 80000cbe <memset>

  r = (struct run*)pa;

  acquire(&kmem.lock);
    80000a08:	00011917          	auipc	s2,0x11
    80000a0c:	87890913          	addi	s2,s2,-1928 # 80011280 <kmem>
    80000a10:	854a                	mv	a0,s2
    80000a12:	00000097          	auipc	ra,0x0
    80000a16:	1b0080e7          	jalr	432(ra) # 80000bc2 <acquire>
  r->next = kmem.freelist;
    80000a1a:	01893783          	ld	a5,24(s2)
    80000a1e:	e09c                	sd	a5,0(s1)
  kmem.freelist = r;
    80000a20:	00993c23          	sd	s1,24(s2)
  release(&kmem.lock);
    80000a24:	854a                	mv	a0,s2
    80000a26:	00000097          	auipc	ra,0x0
    80000a2a:	250080e7          	jalr	592(ra) # 80000c76 <release>
}
    80000a2e:	60e2                	ld	ra,24(sp)
    80000a30:	6442                	ld	s0,16(sp)
    80000a32:	64a2                	ld	s1,8(sp)
    80000a34:	6902                	ld	s2,0(sp)
    80000a36:	6105                	addi	sp,sp,32
    80000a38:	8082                	ret
    panic("kfree");
    80000a3a:	00007517          	auipc	a0,0x7
    80000a3e:	62650513          	addi	a0,a0,1574 # 80008060 <digits+0x20>
    80000a42:	00000097          	auipc	ra,0x0
    80000a46:	aea080e7          	jalr	-1302(ra) # 8000052c <panic>

0000000080000a4a <freerange>:
{
    80000a4a:	7179                	addi	sp,sp,-48
    80000a4c:	f406                	sd	ra,40(sp)
    80000a4e:	f022                	sd	s0,32(sp)
    80000a50:	ec26                	sd	s1,24(sp)
    80000a52:	e84a                	sd	s2,16(sp)
    80000a54:	e44e                	sd	s3,8(sp)
    80000a56:	e052                	sd	s4,0(sp)
    80000a58:	1800                	addi	s0,sp,48
  p = (char*)PGROUNDUP((uint64)pa_start);
    80000a5a:	6785                	lui	a5,0x1
    80000a5c:	fff78713          	addi	a4,a5,-1 # fff <_entry-0x7ffff001>
    80000a60:	00e504b3          	add	s1,a0,a4
    80000a64:	777d                	lui	a4,0xfffff
    80000a66:	8cf9                	and	s1,s1,a4
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000a68:	94be                	add	s1,s1,a5
    80000a6a:	0095ee63          	bltu	a1,s1,80000a86 <freerange+0x3c>
    80000a6e:	892e                	mv	s2,a1
    kfree(p);
    80000a70:	7a7d                	lui	s4,0xfffff
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000a72:	6985                	lui	s3,0x1
    kfree(p);
    80000a74:	01448533          	add	a0,s1,s4
    80000a78:	00000097          	auipc	ra,0x0
    80000a7c:	f5c080e7          	jalr	-164(ra) # 800009d4 <kfree>
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000a80:	94ce                	add	s1,s1,s3
    80000a82:	fe9979e3          	bgeu	s2,s1,80000a74 <freerange+0x2a>
}
    80000a86:	70a2                	ld	ra,40(sp)
    80000a88:	7402                	ld	s0,32(sp)
    80000a8a:	64e2                	ld	s1,24(sp)
    80000a8c:	6942                	ld	s2,16(sp)
    80000a8e:	69a2                	ld	s3,8(sp)
    80000a90:	6a02                	ld	s4,0(sp)
    80000a92:	6145                	addi	sp,sp,48
    80000a94:	8082                	ret

0000000080000a96 <kinit>:
{
    80000a96:	1141                	addi	sp,sp,-16
    80000a98:	e406                	sd	ra,8(sp)
    80000a9a:	e022                	sd	s0,0(sp)
    80000a9c:	0800                	addi	s0,sp,16
  initlock(&kmem.lock, "kmem");
    80000a9e:	00007597          	auipc	a1,0x7
    80000aa2:	5ca58593          	addi	a1,a1,1482 # 80008068 <digits+0x28>
    80000aa6:	00010517          	auipc	a0,0x10
    80000aaa:	7da50513          	addi	a0,a0,2010 # 80011280 <kmem>
    80000aae:	00000097          	auipc	ra,0x0
    80000ab2:	084080e7          	jalr	132(ra) # 80000b32 <initlock>
  freerange(end, (void*)PHYSTOP);
    80000ab6:	45c5                	li	a1,17
    80000ab8:	05ee                	slli	a1,a1,0x1b
    80000aba:	00020517          	auipc	a0,0x20
    80000abe:	54650513          	addi	a0,a0,1350 # 80021000 <end>
    80000ac2:	00000097          	auipc	ra,0x0
    80000ac6:	f88080e7          	jalr	-120(ra) # 80000a4a <freerange>
}
    80000aca:	60a2                	ld	ra,8(sp)
    80000acc:	6402                	ld	s0,0(sp)
    80000ace:	0141                	addi	sp,sp,16
    80000ad0:	8082                	ret

0000000080000ad2 <kalloc>:
// Allocate one 4096-byte page of physical memory.
// Returns a pointer that the kernel can use.
// Returns 0 if the memory cannot be allocated.
void *
kalloc(void)
{
    80000ad2:	1101                	addi	sp,sp,-32
    80000ad4:	ec06                	sd	ra,24(sp)
    80000ad6:	e822                	sd	s0,16(sp)
    80000ad8:	e426                	sd	s1,8(sp)
    80000ada:	1000                	addi	s0,sp,32
  struct run *r;

  acquire(&kmem.lock);
    80000adc:	00010497          	auipc	s1,0x10
    80000ae0:	7a448493          	addi	s1,s1,1956 # 80011280 <kmem>
    80000ae4:	8526                	mv	a0,s1
    80000ae6:	00000097          	auipc	ra,0x0
    80000aea:	0dc080e7          	jalr	220(ra) # 80000bc2 <acquire>
  r = kmem.freelist;
    80000aee:	6c84                	ld	s1,24(s1)
  if(r)
    80000af0:	c885                	beqz	s1,80000b20 <kalloc+0x4e>
    kmem.freelist = r->next;
    80000af2:	609c                	ld	a5,0(s1)
    80000af4:	00010517          	auipc	a0,0x10
    80000af8:	78c50513          	addi	a0,a0,1932 # 80011280 <kmem>
    80000afc:	ed1c                	sd	a5,24(a0)
  release(&kmem.lock);
    80000afe:	00000097          	auipc	ra,0x0
    80000b02:	178080e7          	jalr	376(ra) # 80000c76 <release>

  if(r)
    memset((char*)r, 5, PGSIZE); // fill with junk
    80000b06:	6605                	lui	a2,0x1
    80000b08:	4595                	li	a1,5
    80000b0a:	8526                	mv	a0,s1
    80000b0c:	00000097          	auipc	ra,0x0
    80000b10:	1b2080e7          	jalr	434(ra) # 80000cbe <memset>
  return (void*)r;
}
    80000b14:	8526                	mv	a0,s1
    80000b16:	60e2                	ld	ra,24(sp)
    80000b18:	6442                	ld	s0,16(sp)
    80000b1a:	64a2                	ld	s1,8(sp)
    80000b1c:	6105                	addi	sp,sp,32
    80000b1e:	8082                	ret
  release(&kmem.lock);
    80000b20:	00010517          	auipc	a0,0x10
    80000b24:	76050513          	addi	a0,a0,1888 # 80011280 <kmem>
    80000b28:	00000097          	auipc	ra,0x0
    80000b2c:	14e080e7          	jalr	334(ra) # 80000c76 <release>
  if(r)
    80000b30:	b7d5                	j	80000b14 <kalloc+0x42>

0000000080000b32 <initlock>:
#include "proc.h"
#include "defs.h"

void
initlock(struct spinlock *lk, char *name)
{
    80000b32:	1141                	addi	sp,sp,-16
    80000b34:	e422                	sd	s0,8(sp)
    80000b36:	0800                	addi	s0,sp,16
  lk->name = name;
    80000b38:	e50c                	sd	a1,8(a0)
  lk->locked = 0;
    80000b3a:	00052023          	sw	zero,0(a0)
  lk->cpu = 0;
    80000b3e:	00053823          	sd	zero,16(a0)
}
    80000b42:	6422                	ld	s0,8(sp)
    80000b44:	0141                	addi	sp,sp,16
    80000b46:	8082                	ret

0000000080000b48 <holding>:
// Interrupts must be off.
int
holding(struct spinlock *lk)
{
  int r;
  r = (lk->locked && lk->cpu == mycpu());
    80000b48:	411c                	lw	a5,0(a0)
    80000b4a:	e399                	bnez	a5,80000b50 <holding+0x8>
    80000b4c:	4501                	li	a0,0
  return r;
}
    80000b4e:	8082                	ret
{
    80000b50:	1101                	addi	sp,sp,-32
    80000b52:	ec06                	sd	ra,24(sp)
    80000b54:	e822                	sd	s0,16(sp)
    80000b56:	e426                	sd	s1,8(sp)
    80000b58:	1000                	addi	s0,sp,32
  r = (lk->locked && lk->cpu == mycpu());
    80000b5a:	6904                	ld	s1,16(a0)
    80000b5c:	00001097          	auipc	ra,0x1
    80000b60:	e32080e7          	jalr	-462(ra) # 8000198e <mycpu>
    80000b64:	40a48533          	sub	a0,s1,a0
    80000b68:	00153513          	seqz	a0,a0
}
    80000b6c:	60e2                	ld	ra,24(sp)
    80000b6e:	6442                	ld	s0,16(sp)
    80000b70:	64a2                	ld	s1,8(sp)
    80000b72:	6105                	addi	sp,sp,32
    80000b74:	8082                	ret

0000000080000b76 <push_off>:
// it takes two pop_off()s to undo two push_off()s.  Also, if interrupts
// are initially off, then push_off, pop_off leaves them off.

void
push_off(void)
{
    80000b76:	1101                	addi	sp,sp,-32
    80000b78:	ec06                	sd	ra,24(sp)
    80000b7a:	e822                	sd	s0,16(sp)
    80000b7c:	e426                	sd	s1,8(sp)
    80000b7e:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000b80:	100024f3          	csrr	s1,sstatus
    80000b84:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    80000b88:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000b8a:	10079073          	csrw	sstatus,a5
  int old = intr_get();

  intr_off();
  if(mycpu()->noff == 0)
    80000b8e:	00001097          	auipc	ra,0x1
    80000b92:	e00080e7          	jalr	-512(ra) # 8000198e <mycpu>
    80000b96:	5d3c                	lw	a5,120(a0)
    80000b98:	cf89                	beqz	a5,80000bb2 <push_off+0x3c>
    mycpu()->intena = old;
  mycpu()->noff += 1;
    80000b9a:	00001097          	auipc	ra,0x1
    80000b9e:	df4080e7          	jalr	-524(ra) # 8000198e <mycpu>
    80000ba2:	5d3c                	lw	a5,120(a0)
    80000ba4:	2785                	addiw	a5,a5,1
    80000ba6:	dd3c                	sw	a5,120(a0)
}
    80000ba8:	60e2                	ld	ra,24(sp)
    80000baa:	6442                	ld	s0,16(sp)
    80000bac:	64a2                	ld	s1,8(sp)
    80000bae:	6105                	addi	sp,sp,32
    80000bb0:	8082                	ret
    mycpu()->intena = old;
    80000bb2:	00001097          	auipc	ra,0x1
    80000bb6:	ddc080e7          	jalr	-548(ra) # 8000198e <mycpu>
  return (x & SSTATUS_SIE) != 0;
    80000bba:	8085                	srli	s1,s1,0x1
    80000bbc:	8885                	andi	s1,s1,1
    80000bbe:	dd64                	sw	s1,124(a0)
    80000bc0:	bfe9                	j	80000b9a <push_off+0x24>

0000000080000bc2 <acquire>:
{
    80000bc2:	1101                	addi	sp,sp,-32
    80000bc4:	ec06                	sd	ra,24(sp)
    80000bc6:	e822                	sd	s0,16(sp)
    80000bc8:	e426                	sd	s1,8(sp)
    80000bca:	1000                	addi	s0,sp,32
    80000bcc:	84aa                	mv	s1,a0
  push_off(); // disable interrupts to avoid deadlock.
    80000bce:	00000097          	auipc	ra,0x0
    80000bd2:	fa8080e7          	jalr	-88(ra) # 80000b76 <push_off>
  if(holding(lk))
    80000bd6:	8526                	mv	a0,s1
    80000bd8:	00000097          	auipc	ra,0x0
    80000bdc:	f70080e7          	jalr	-144(ra) # 80000b48 <holding>
  while(__sync_lock_test_and_set(&lk->locked, 1) != 0)
    80000be0:	4705                	li	a4,1
  if(holding(lk))
    80000be2:	e115                	bnez	a0,80000c06 <acquire+0x44>
  while(__sync_lock_test_and_set(&lk->locked, 1) != 0)
    80000be4:	87ba                	mv	a5,a4
    80000be6:	0cf4a7af          	amoswap.w.aq	a5,a5,(s1)
    80000bea:	2781                	sext.w	a5,a5
    80000bec:	ffe5                	bnez	a5,80000be4 <acquire+0x22>
  __sync_synchronize();
    80000bee:	0ff0000f          	fence
  lk->cpu = mycpu();
    80000bf2:	00001097          	auipc	ra,0x1
    80000bf6:	d9c080e7          	jalr	-612(ra) # 8000198e <mycpu>
    80000bfa:	e888                	sd	a0,16(s1)
}
    80000bfc:	60e2                	ld	ra,24(sp)
    80000bfe:	6442                	ld	s0,16(sp)
    80000c00:	64a2                	ld	s1,8(sp)
    80000c02:	6105                	addi	sp,sp,32
    80000c04:	8082                	ret
    panic("acquire");
    80000c06:	00007517          	auipc	a0,0x7
    80000c0a:	46a50513          	addi	a0,a0,1130 # 80008070 <digits+0x30>
    80000c0e:	00000097          	auipc	ra,0x0
    80000c12:	91e080e7          	jalr	-1762(ra) # 8000052c <panic>

0000000080000c16 <pop_off>:

void
pop_off(void)
{
    80000c16:	1141                	addi	sp,sp,-16
    80000c18:	e406                	sd	ra,8(sp)
    80000c1a:	e022                	sd	s0,0(sp)
    80000c1c:	0800                	addi	s0,sp,16
  struct cpu *c = mycpu();
    80000c1e:	00001097          	auipc	ra,0x1
    80000c22:	d70080e7          	jalr	-656(ra) # 8000198e <mycpu>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000c26:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80000c2a:	8b89                	andi	a5,a5,2
  if(intr_get())
    80000c2c:	e78d                	bnez	a5,80000c56 <pop_off+0x40>
    panic("pop_off - interruptible");
  if(c->noff < 1)
    80000c2e:	5d3c                	lw	a5,120(a0)
    80000c30:	02f05b63          	blez	a5,80000c66 <pop_off+0x50>
    panic("pop_off");
  c->noff -= 1;
    80000c34:	37fd                	addiw	a5,a5,-1
    80000c36:	0007871b          	sext.w	a4,a5
    80000c3a:	dd3c                	sw	a5,120(a0)
  if(c->noff == 0 && c->intena)
    80000c3c:	eb09                	bnez	a4,80000c4e <pop_off+0x38>
    80000c3e:	5d7c                	lw	a5,124(a0)
    80000c40:	c799                	beqz	a5,80000c4e <pop_off+0x38>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000c42:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80000c46:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000c4a:	10079073          	csrw	sstatus,a5
    intr_on();
}
    80000c4e:	60a2                	ld	ra,8(sp)
    80000c50:	6402                	ld	s0,0(sp)
    80000c52:	0141                	addi	sp,sp,16
    80000c54:	8082                	ret
    panic("pop_off - interruptible");
    80000c56:	00007517          	auipc	a0,0x7
    80000c5a:	42250513          	addi	a0,a0,1058 # 80008078 <digits+0x38>
    80000c5e:	00000097          	auipc	ra,0x0
    80000c62:	8ce080e7          	jalr	-1842(ra) # 8000052c <panic>
    panic("pop_off");
    80000c66:	00007517          	auipc	a0,0x7
    80000c6a:	42a50513          	addi	a0,a0,1066 # 80008090 <digits+0x50>
    80000c6e:	00000097          	auipc	ra,0x0
    80000c72:	8be080e7          	jalr	-1858(ra) # 8000052c <panic>

0000000080000c76 <release>:
{
    80000c76:	1101                	addi	sp,sp,-32
    80000c78:	ec06                	sd	ra,24(sp)
    80000c7a:	e822                	sd	s0,16(sp)
    80000c7c:	e426                	sd	s1,8(sp)
    80000c7e:	1000                	addi	s0,sp,32
    80000c80:	84aa                	mv	s1,a0
  if(!holding(lk))
    80000c82:	00000097          	auipc	ra,0x0
    80000c86:	ec6080e7          	jalr	-314(ra) # 80000b48 <holding>
    80000c8a:	c115                	beqz	a0,80000cae <release+0x38>
  lk->cpu = 0;
    80000c8c:	0004b823          	sd	zero,16(s1)
  __sync_synchronize();
    80000c90:	0ff0000f          	fence
  __sync_lock_release(&lk->locked);
    80000c94:	0f50000f          	fence	iorw,ow
    80000c98:	0804a02f          	amoswap.w	zero,zero,(s1)
  pop_off();
    80000c9c:	00000097          	auipc	ra,0x0
    80000ca0:	f7a080e7          	jalr	-134(ra) # 80000c16 <pop_off>
}
    80000ca4:	60e2                	ld	ra,24(sp)
    80000ca6:	6442                	ld	s0,16(sp)
    80000ca8:	64a2                	ld	s1,8(sp)
    80000caa:	6105                	addi	sp,sp,32
    80000cac:	8082                	ret
    panic("release");
    80000cae:	00007517          	auipc	a0,0x7
    80000cb2:	3ea50513          	addi	a0,a0,1002 # 80008098 <digits+0x58>
    80000cb6:	00000097          	auipc	ra,0x0
    80000cba:	876080e7          	jalr	-1930(ra) # 8000052c <panic>

0000000080000cbe <memset>:
#include "types.h"

void*
memset(void *dst, int c, uint n)
{
    80000cbe:	1141                	addi	sp,sp,-16
    80000cc0:	e422                	sd	s0,8(sp)
    80000cc2:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
    80000cc4:	ca19                	beqz	a2,80000cda <memset+0x1c>
    80000cc6:	87aa                	mv	a5,a0
    80000cc8:	1602                	slli	a2,a2,0x20
    80000cca:	9201                	srli	a2,a2,0x20
    80000ccc:	00a60733          	add	a4,a2,a0
    cdst[i] = c;
    80000cd0:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
    80000cd4:	0785                	addi	a5,a5,1
    80000cd6:	fee79de3          	bne	a5,a4,80000cd0 <memset+0x12>
  }
  return dst;
}
    80000cda:	6422                	ld	s0,8(sp)
    80000cdc:	0141                	addi	sp,sp,16
    80000cde:	8082                	ret

0000000080000ce0 <memcmp>:

int
memcmp(const void *v1, const void *v2, uint n)
{
    80000ce0:	1141                	addi	sp,sp,-16
    80000ce2:	e422                	sd	s0,8(sp)
    80000ce4:	0800                	addi	s0,sp,16
  const uchar *s1, *s2;

  s1 = v1;
  s2 = v2;
  while(n-- > 0){
    80000ce6:	ca05                	beqz	a2,80000d16 <memcmp+0x36>
    80000ce8:	fff6069b          	addiw	a3,a2,-1 # fff <_entry-0x7ffff001>
    80000cec:	1682                	slli	a3,a3,0x20
    80000cee:	9281                	srli	a3,a3,0x20
    80000cf0:	0685                	addi	a3,a3,1
    80000cf2:	96aa                	add	a3,a3,a0
    if(*s1 != *s2)
    80000cf4:	00054783          	lbu	a5,0(a0)
    80000cf8:	0005c703          	lbu	a4,0(a1)
    80000cfc:	00e79863          	bne	a5,a4,80000d0c <memcmp+0x2c>
      return *s1 - *s2;
    s1++, s2++;
    80000d00:	0505                	addi	a0,a0,1
    80000d02:	0585                	addi	a1,a1,1
  while(n-- > 0){
    80000d04:	fed518e3          	bne	a0,a3,80000cf4 <memcmp+0x14>
  }

  return 0;
    80000d08:	4501                	li	a0,0
    80000d0a:	a019                	j	80000d10 <memcmp+0x30>
      return *s1 - *s2;
    80000d0c:	40e7853b          	subw	a0,a5,a4
}
    80000d10:	6422                	ld	s0,8(sp)
    80000d12:	0141                	addi	sp,sp,16
    80000d14:	8082                	ret
  return 0;
    80000d16:	4501                	li	a0,0
    80000d18:	bfe5                	j	80000d10 <memcmp+0x30>

0000000080000d1a <memmove>:

void*
memmove(void *dst, const void *src, uint n)
{
    80000d1a:	1141                	addi	sp,sp,-16
    80000d1c:	e422                	sd	s0,8(sp)
    80000d1e:	0800                	addi	s0,sp,16
  const char *s;
  char *d;

  s = src;
  d = dst;
  if(s < d && s + n > d){
    80000d20:	02a5e563          	bltu	a1,a0,80000d4a <memmove+0x30>
    s += n;
    d += n;
    while(n-- > 0)
      *--d = *--s;
  } else
    while(n-- > 0)
    80000d24:	fff6069b          	addiw	a3,a2,-1
    80000d28:	ce11                	beqz	a2,80000d44 <memmove+0x2a>
    80000d2a:	1682                	slli	a3,a3,0x20
    80000d2c:	9281                	srli	a3,a3,0x20
    80000d2e:	0685                	addi	a3,a3,1
    80000d30:	96ae                	add	a3,a3,a1
    80000d32:	87aa                	mv	a5,a0
      *d++ = *s++;
    80000d34:	0585                	addi	a1,a1,1
    80000d36:	0785                	addi	a5,a5,1
    80000d38:	fff5c703          	lbu	a4,-1(a1)
    80000d3c:	fee78fa3          	sb	a4,-1(a5)
    while(n-- > 0)
    80000d40:	fed59ae3          	bne	a1,a3,80000d34 <memmove+0x1a>

  return dst;
}
    80000d44:	6422                	ld	s0,8(sp)
    80000d46:	0141                	addi	sp,sp,16
    80000d48:	8082                	ret
  if(s < d && s + n > d){
    80000d4a:	02061713          	slli	a4,a2,0x20
    80000d4e:	9301                	srli	a4,a4,0x20
    80000d50:	00e587b3          	add	a5,a1,a4
    80000d54:	fcf578e3          	bgeu	a0,a5,80000d24 <memmove+0xa>
    d += n;
    80000d58:	972a                	add	a4,a4,a0
    while(n-- > 0)
    80000d5a:	fff6069b          	addiw	a3,a2,-1
    80000d5e:	d27d                	beqz	a2,80000d44 <memmove+0x2a>
    80000d60:	02069613          	slli	a2,a3,0x20
    80000d64:	9201                	srli	a2,a2,0x20
    80000d66:	fff64613          	not	a2,a2
    80000d6a:	963e                	add	a2,a2,a5
      *--d = *--s;
    80000d6c:	17fd                	addi	a5,a5,-1
    80000d6e:	177d                	addi	a4,a4,-1 # ffffffffffffefff <end+0xffffffff7ffddfff>
    80000d70:	0007c683          	lbu	a3,0(a5)
    80000d74:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
    80000d78:	fef61ae3          	bne	a2,a5,80000d6c <memmove+0x52>
    80000d7c:	b7e1                	j	80000d44 <memmove+0x2a>

0000000080000d7e <memcpy>:

// memcpy exists to placate GCC.  Use memmove.
void*
memcpy(void *dst, const void *src, uint n)
{
    80000d7e:	1141                	addi	sp,sp,-16
    80000d80:	e406                	sd	ra,8(sp)
    80000d82:	e022                	sd	s0,0(sp)
    80000d84:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
    80000d86:	00000097          	auipc	ra,0x0
    80000d8a:	f94080e7          	jalr	-108(ra) # 80000d1a <memmove>
}
    80000d8e:	60a2                	ld	ra,8(sp)
    80000d90:	6402                	ld	s0,0(sp)
    80000d92:	0141                	addi	sp,sp,16
    80000d94:	8082                	ret

0000000080000d96 <strncmp>:

int
strncmp(const char *p, const char *q, uint n)
{
    80000d96:	1141                	addi	sp,sp,-16
    80000d98:	e422                	sd	s0,8(sp)
    80000d9a:	0800                	addi	s0,sp,16
  while(n > 0 && *p && *p == *q)
    80000d9c:	ce11                	beqz	a2,80000db8 <strncmp+0x22>
    80000d9e:	00054783          	lbu	a5,0(a0)
    80000da2:	cf89                	beqz	a5,80000dbc <strncmp+0x26>
    80000da4:	0005c703          	lbu	a4,0(a1)
    80000da8:	00f71a63          	bne	a4,a5,80000dbc <strncmp+0x26>
    n--, p++, q++;
    80000dac:	367d                	addiw	a2,a2,-1
    80000dae:	0505                	addi	a0,a0,1
    80000db0:	0585                	addi	a1,a1,1
  while(n > 0 && *p && *p == *q)
    80000db2:	f675                	bnez	a2,80000d9e <strncmp+0x8>
  if(n == 0)
    return 0;
    80000db4:	4501                	li	a0,0
    80000db6:	a809                	j	80000dc8 <strncmp+0x32>
    80000db8:	4501                	li	a0,0
    80000dba:	a039                	j	80000dc8 <strncmp+0x32>
  if(n == 0)
    80000dbc:	ca09                	beqz	a2,80000dce <strncmp+0x38>
  return (uchar)*p - (uchar)*q;
    80000dbe:	00054503          	lbu	a0,0(a0)
    80000dc2:	0005c783          	lbu	a5,0(a1)
    80000dc6:	9d1d                	subw	a0,a0,a5
}
    80000dc8:	6422                	ld	s0,8(sp)
    80000dca:	0141                	addi	sp,sp,16
    80000dcc:	8082                	ret
    return 0;
    80000dce:	4501                	li	a0,0
    80000dd0:	bfe5                	j	80000dc8 <strncmp+0x32>

0000000080000dd2 <strncpy>:

char*
strncpy(char *s, const char *t, int n)
{
    80000dd2:	1141                	addi	sp,sp,-16
    80000dd4:	e422                	sd	s0,8(sp)
    80000dd6:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while(n-- > 0 && (*s++ = *t++) != 0)
    80000dd8:	872a                	mv	a4,a0
    80000dda:	8832                	mv	a6,a2
    80000ddc:	367d                	addiw	a2,a2,-1
    80000dde:	01005963          	blez	a6,80000df0 <strncpy+0x1e>
    80000de2:	0705                	addi	a4,a4,1
    80000de4:	0005c783          	lbu	a5,0(a1)
    80000de8:	fef70fa3          	sb	a5,-1(a4)
    80000dec:	0585                	addi	a1,a1,1
    80000dee:	f7f5                	bnez	a5,80000dda <strncpy+0x8>
    ;
  while(n-- > 0)
    80000df0:	86ba                	mv	a3,a4
    80000df2:	00c05c63          	blez	a2,80000e0a <strncpy+0x38>
    *s++ = 0;
    80000df6:	0685                	addi	a3,a3,1
    80000df8:	fe068fa3          	sb	zero,-1(a3)
  while(n-- > 0)
    80000dfc:	40d707bb          	subw	a5,a4,a3
    80000e00:	37fd                	addiw	a5,a5,-1
    80000e02:	010787bb          	addw	a5,a5,a6
    80000e06:	fef048e3          	bgtz	a5,80000df6 <strncpy+0x24>
  return os;
}
    80000e0a:	6422                	ld	s0,8(sp)
    80000e0c:	0141                	addi	sp,sp,16
    80000e0e:	8082                	ret

0000000080000e10 <safestrcpy>:

// Like strncpy but guaranteed to NUL-terminate.
char*
safestrcpy(char *s, const char *t, int n)
{
    80000e10:	1141                	addi	sp,sp,-16
    80000e12:	e422                	sd	s0,8(sp)
    80000e14:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  if(n <= 0)
    80000e16:	02c05363          	blez	a2,80000e3c <safestrcpy+0x2c>
    80000e1a:	fff6069b          	addiw	a3,a2,-1
    80000e1e:	1682                	slli	a3,a3,0x20
    80000e20:	9281                	srli	a3,a3,0x20
    80000e22:	96ae                	add	a3,a3,a1
    80000e24:	87aa                	mv	a5,a0
    return os;
  while(--n > 0 && (*s++ = *t++) != 0)
    80000e26:	00d58963          	beq	a1,a3,80000e38 <safestrcpy+0x28>
    80000e2a:	0585                	addi	a1,a1,1
    80000e2c:	0785                	addi	a5,a5,1
    80000e2e:	fff5c703          	lbu	a4,-1(a1)
    80000e32:	fee78fa3          	sb	a4,-1(a5)
    80000e36:	fb65                	bnez	a4,80000e26 <safestrcpy+0x16>
    ;
  *s = 0;
    80000e38:	00078023          	sb	zero,0(a5)
  return os;
}
    80000e3c:	6422                	ld	s0,8(sp)
    80000e3e:	0141                	addi	sp,sp,16
    80000e40:	8082                	ret

0000000080000e42 <strlen>:

int
strlen(const char *s)
{
    80000e42:	1141                	addi	sp,sp,-16
    80000e44:	e422                	sd	s0,8(sp)
    80000e46:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
    80000e48:	00054783          	lbu	a5,0(a0)
    80000e4c:	cf91                	beqz	a5,80000e68 <strlen+0x26>
    80000e4e:	0505                	addi	a0,a0,1
    80000e50:	87aa                	mv	a5,a0
    80000e52:	4685                	li	a3,1
    80000e54:	9e89                	subw	a3,a3,a0
    80000e56:	00f6853b          	addw	a0,a3,a5
    80000e5a:	0785                	addi	a5,a5,1
    80000e5c:	fff7c703          	lbu	a4,-1(a5)
    80000e60:	fb7d                	bnez	a4,80000e56 <strlen+0x14>
    ;
  return n;
}
    80000e62:	6422                	ld	s0,8(sp)
    80000e64:	0141                	addi	sp,sp,16
    80000e66:	8082                	ret
  for(n = 0; s[n]; n++)
    80000e68:	4501                	li	a0,0
    80000e6a:	bfe5                	j	80000e62 <strlen+0x20>

0000000080000e6c <main>:
volatile static int started = 0;

// start() jumps here in supervisor mode on all CPUs.
void
main()
{
    80000e6c:	1141                	addi	sp,sp,-16
    80000e6e:	e406                	sd	ra,8(sp)
    80000e70:	e022                	sd	s0,0(sp)
    80000e72:	0800                	addi	s0,sp,16
  if(cpuid() == 0){
    80000e74:	00001097          	auipc	ra,0x1
    80000e78:	b0a080e7          	jalr	-1270(ra) # 8000197e <cpuid>
    virtio_disk_init(); // emulated hard disk
    userinit();      // first user process
    __sync_synchronize();
    started = 1;
  } else {
    while(started == 0)
    80000e7c:	00008717          	auipc	a4,0x8
    80000e80:	19c70713          	addi	a4,a4,412 # 80009018 <started>
  if(cpuid() == 0){
    80000e84:	c139                	beqz	a0,80000eca <main+0x5e>
    while(started == 0)
    80000e86:	431c                	lw	a5,0(a4)
    80000e88:	2781                	sext.w	a5,a5
    80000e8a:	dff5                	beqz	a5,80000e86 <main+0x1a>
      ;
    __sync_synchronize();
    80000e8c:	0ff0000f          	fence
    printf("hart %d starting\n", cpuid());
    80000e90:	00001097          	auipc	ra,0x1
    80000e94:	aee080e7          	jalr	-1298(ra) # 8000197e <cpuid>
    80000e98:	85aa                	mv	a1,a0
    80000e9a:	00007517          	auipc	a0,0x7
    80000e9e:	21e50513          	addi	a0,a0,542 # 800080b8 <digits+0x78>
    80000ea2:	fffff097          	auipc	ra,0xfffff
    80000ea6:	6d4080e7          	jalr	1748(ra) # 80000576 <printf>
    kvminithart();    // turn on paging
    80000eaa:	00000097          	auipc	ra,0x0
    80000eae:	0d8080e7          	jalr	216(ra) # 80000f82 <kvminithart>
    trapinithart();   // install kernel trap vector
    80000eb2:	00001097          	auipc	ra,0x1
    80000eb6:	758080e7          	jalr	1880(ra) # 8000260a <trapinithart>
    plicinithart();   // ask PLIC for device interrupts
    80000eba:	00005097          	auipc	ra,0x5
    80000ebe:	f26080e7          	jalr	-218(ra) # 80005de0 <plicinithart>
  }

  scheduler();        
    80000ec2:	00001097          	auipc	ra,0x1
    80000ec6:	020080e7          	jalr	32(ra) # 80001ee2 <scheduler>
    consoleinit();
    80000eca:	fffff097          	auipc	ra,0xfffff
    80000ece:	572080e7          	jalr	1394(ra) # 8000043c <consoleinit>
    printfinit();
    80000ed2:	00000097          	auipc	ra,0x0
    80000ed6:	884080e7          	jalr	-1916(ra) # 80000756 <printfinit>
    printf("\n");
    80000eda:	00007517          	auipc	a0,0x7
    80000ede:	1ee50513          	addi	a0,a0,494 # 800080c8 <digits+0x88>
    80000ee2:	fffff097          	auipc	ra,0xfffff
    80000ee6:	694080e7          	jalr	1684(ra) # 80000576 <printf>
    printf("xv6 kernel is booting\n");
    80000eea:	00007517          	auipc	a0,0x7
    80000eee:	1b650513          	addi	a0,a0,438 # 800080a0 <digits+0x60>
    80000ef2:	fffff097          	auipc	ra,0xfffff
    80000ef6:	684080e7          	jalr	1668(ra) # 80000576 <printf>
    printf("\n");
    80000efa:	00007517          	auipc	a0,0x7
    80000efe:	1ce50513          	addi	a0,a0,462 # 800080c8 <digits+0x88>
    80000f02:	fffff097          	auipc	ra,0xfffff
    80000f06:	674080e7          	jalr	1652(ra) # 80000576 <printf>
    kinit();         // physical page allocator
    80000f0a:	00000097          	auipc	ra,0x0
    80000f0e:	b8c080e7          	jalr	-1140(ra) # 80000a96 <kinit>
    kvminit();       // create kernel page table
    80000f12:	00000097          	auipc	ra,0x0
    80000f16:	310080e7          	jalr	784(ra) # 80001222 <kvminit>
    kvminithart();   // turn on paging
    80000f1a:	00000097          	auipc	ra,0x0
    80000f1e:	068080e7          	jalr	104(ra) # 80000f82 <kvminithart>
    procinit();      // process table
    80000f22:	00001097          	auipc	ra,0x1
    80000f26:	9c4080e7          	jalr	-1596(ra) # 800018e6 <procinit>
    trapinit();      // trap vectors
    80000f2a:	00001097          	auipc	ra,0x1
    80000f2e:	6b8080e7          	jalr	1720(ra) # 800025e2 <trapinit>
    trapinithart();  // install kernel trap vector
    80000f32:	00001097          	auipc	ra,0x1
    80000f36:	6d8080e7          	jalr	1752(ra) # 8000260a <trapinithart>
    plicinit();      // set up interrupt controller
    80000f3a:	00005097          	auipc	ra,0x5
    80000f3e:	e90080e7          	jalr	-368(ra) # 80005dca <plicinit>
    plicinithart();  // ask PLIC for device interrupts
    80000f42:	00005097          	auipc	ra,0x5
    80000f46:	e9e080e7          	jalr	-354(ra) # 80005de0 <plicinithart>
    binit();         // buffer cache
    80000f4a:	00002097          	auipc	ra,0x2
    80000f4e:	e02080e7          	jalr	-510(ra) # 80002d4c <binit>
    iinit();         // inode cache
    80000f52:	00002097          	auipc	ra,0x2
    80000f56:	558080e7          	jalr	1368(ra) # 800034aa <iinit>
    fileinit();      // file table
    80000f5a:	00003097          	auipc	ra,0x3
    80000f5e:	620080e7          	jalr	1568(ra) # 8000457a <fileinit>
    virtio_disk_init(); // emulated hard disk
    80000f62:	00005097          	auipc	ra,0x5
    80000f66:	f9e080e7          	jalr	-98(ra) # 80005f00 <virtio_disk_init>
    userinit();      // first user process
    80000f6a:	00001097          	auipc	ra,0x1
    80000f6e:	d0a080e7          	jalr	-758(ra) # 80001c74 <userinit>
    __sync_synchronize();
    80000f72:	0ff0000f          	fence
    started = 1;
    80000f76:	4785                	li	a5,1
    80000f78:	00008717          	auipc	a4,0x8
    80000f7c:	0af72023          	sw	a5,160(a4) # 80009018 <started>
    80000f80:	b789                	j	80000ec2 <main+0x56>

0000000080000f82 <kvminithart>:

// Switch h/w page table register to the kernel's page table,
// and enable paging.
void
kvminithart()
{
    80000f82:	1141                	addi	sp,sp,-16
    80000f84:	e422                	sd	s0,8(sp)
    80000f86:	0800                	addi	s0,sp,16
  w_satp(MAKE_SATP(kernel_pagetable));
    80000f88:	00008797          	auipc	a5,0x8
    80000f8c:	0987b783          	ld	a5,152(a5) # 80009020 <kernel_pagetable>
    80000f90:	83b1                	srli	a5,a5,0xc
    80000f92:	577d                	li	a4,-1
    80000f94:	177e                	slli	a4,a4,0x3f
    80000f96:	8fd9                	or	a5,a5,a4
  asm volatile("csrw satp, %0" : : "r" (x));
    80000f98:	18079073          	csrw	satp,a5
// flush the TLB.
static inline void
sfence_vma()
{
  // the zero, zero means flush all TLB entries.
  asm volatile("sfence.vma zero, zero");
    80000f9c:	12000073          	sfence.vma
  sfence_vma();
}
    80000fa0:	6422                	ld	s0,8(sp)
    80000fa2:	0141                	addi	sp,sp,16
    80000fa4:	8082                	ret

0000000080000fa6 <walk>:
//   21..29 -- 9 bits of level-1 index.
//   12..20 -- 9 bits of level-0 index.
//    0..11 -- 12 bits of byte offset within the page.
pte_t *
walk(pagetable_t pagetable, uint64 va, int alloc)
{
    80000fa6:	7139                	addi	sp,sp,-64
    80000fa8:	fc06                	sd	ra,56(sp)
    80000faa:	f822                	sd	s0,48(sp)
    80000fac:	f426                	sd	s1,40(sp)
    80000fae:	f04a                	sd	s2,32(sp)
    80000fb0:	ec4e                	sd	s3,24(sp)
    80000fb2:	e852                	sd	s4,16(sp)
    80000fb4:	e456                	sd	s5,8(sp)
    80000fb6:	e05a                	sd	s6,0(sp)
    80000fb8:	0080                	addi	s0,sp,64
    80000fba:	84aa                	mv	s1,a0
    80000fbc:	89ae                	mv	s3,a1
    80000fbe:	8ab2                	mv	s5,a2
  if(va >= MAXVA)
    80000fc0:	57fd                	li	a5,-1
    80000fc2:	83e9                	srli	a5,a5,0x1a
    80000fc4:	4a79                	li	s4,30
    panic("walk");

  for(int level = 2; level > 0; level--) {
    80000fc6:	4b31                	li	s6,12
  if(va >= MAXVA)
    80000fc8:	04b7f263          	bgeu	a5,a1,8000100c <walk+0x66>
    panic("walk");
    80000fcc:	00007517          	auipc	a0,0x7
    80000fd0:	10450513          	addi	a0,a0,260 # 800080d0 <digits+0x90>
    80000fd4:	fffff097          	auipc	ra,0xfffff
    80000fd8:	558080e7          	jalr	1368(ra) # 8000052c <panic>
    pte_t *pte = &pagetable[PX(level, va)];
    if(*pte & PTE_V) {
      pagetable = (pagetable_t)PTE2PA(*pte);
    } else {
      if(!alloc || (pagetable = (pde_t*)kalloc()) == 0)
    80000fdc:	060a8663          	beqz	s5,80001048 <walk+0xa2>
    80000fe0:	00000097          	auipc	ra,0x0
    80000fe4:	af2080e7          	jalr	-1294(ra) # 80000ad2 <kalloc>
    80000fe8:	84aa                	mv	s1,a0
    80000fea:	c529                	beqz	a0,80001034 <walk+0x8e>
        return 0;
      memset(pagetable, 0, PGSIZE);
    80000fec:	6605                	lui	a2,0x1
    80000fee:	4581                	li	a1,0
    80000ff0:	00000097          	auipc	ra,0x0
    80000ff4:	cce080e7          	jalr	-818(ra) # 80000cbe <memset>
      *pte = PA2PTE(pagetable) | PTE_V;
    80000ff8:	00c4d793          	srli	a5,s1,0xc
    80000ffc:	07aa                	slli	a5,a5,0xa
    80000ffe:	0017e793          	ori	a5,a5,1
    80001002:	00f93023          	sd	a5,0(s2)
  for(int level = 2; level > 0; level--) {
    80001006:	3a5d                	addiw	s4,s4,-9 # ffffffffffffeff7 <end+0xffffffff7ffddff7>
    80001008:	036a0063          	beq	s4,s6,80001028 <walk+0x82>
    pte_t *pte = &pagetable[PX(level, va)];
    8000100c:	0149d933          	srl	s2,s3,s4
    80001010:	1ff97913          	andi	s2,s2,511
    80001014:	090e                	slli	s2,s2,0x3
    80001016:	9926                	add	s2,s2,s1
    if(*pte & PTE_V) {
    80001018:	00093483          	ld	s1,0(s2)
    8000101c:	0014f793          	andi	a5,s1,1
    80001020:	dfd5                	beqz	a5,80000fdc <walk+0x36>
      pagetable = (pagetable_t)PTE2PA(*pte);
    80001022:	80a9                	srli	s1,s1,0xa
    80001024:	04b2                	slli	s1,s1,0xc
    80001026:	b7c5                	j	80001006 <walk+0x60>
    }
  }
  return &pagetable[PX(0, va)];
    80001028:	00c9d513          	srli	a0,s3,0xc
    8000102c:	1ff57513          	andi	a0,a0,511
    80001030:	050e                	slli	a0,a0,0x3
    80001032:	9526                	add	a0,a0,s1
}
    80001034:	70e2                	ld	ra,56(sp)
    80001036:	7442                	ld	s0,48(sp)
    80001038:	74a2                	ld	s1,40(sp)
    8000103a:	7902                	ld	s2,32(sp)
    8000103c:	69e2                	ld	s3,24(sp)
    8000103e:	6a42                	ld	s4,16(sp)
    80001040:	6aa2                	ld	s5,8(sp)
    80001042:	6b02                	ld	s6,0(sp)
    80001044:	6121                	addi	sp,sp,64
    80001046:	8082                	ret
        return 0;
    80001048:	4501                	li	a0,0
    8000104a:	b7ed                	j	80001034 <walk+0x8e>

000000008000104c <walkaddr>:
walkaddr(pagetable_t pagetable, uint64 va)
{
  pte_t *pte;
  uint64 pa;

  if(va >= MAXVA)
    8000104c:	57fd                	li	a5,-1
    8000104e:	83e9                	srli	a5,a5,0x1a
    80001050:	00b7f463          	bgeu	a5,a1,80001058 <walkaddr+0xc>
    return 0;
    80001054:	4501                	li	a0,0
    return 0;
  if((*pte & PTE_U) == 0)
    return 0;
  pa = PTE2PA(*pte);
  return pa;
}
    80001056:	8082                	ret
{
    80001058:	1141                	addi	sp,sp,-16
    8000105a:	e406                	sd	ra,8(sp)
    8000105c:	e022                	sd	s0,0(sp)
    8000105e:	0800                	addi	s0,sp,16
  pte = walk(pagetable, va, 0);
    80001060:	4601                	li	a2,0
    80001062:	00000097          	auipc	ra,0x0
    80001066:	f44080e7          	jalr	-188(ra) # 80000fa6 <walk>
  if(pte == 0)
    8000106a:	c105                	beqz	a0,8000108a <walkaddr+0x3e>
  if((*pte & PTE_V) == 0)
    8000106c:	611c                	ld	a5,0(a0)
  if((*pte & PTE_U) == 0)
    8000106e:	0117f693          	andi	a3,a5,17
    80001072:	4745                	li	a4,17
    return 0;
    80001074:	4501                	li	a0,0
  if((*pte & PTE_U) == 0)
    80001076:	00e68663          	beq	a3,a4,80001082 <walkaddr+0x36>
}
    8000107a:	60a2                	ld	ra,8(sp)
    8000107c:	6402                	ld	s0,0(sp)
    8000107e:	0141                	addi	sp,sp,16
    80001080:	8082                	ret
  pa = PTE2PA(*pte);
    80001082:	83a9                	srli	a5,a5,0xa
    80001084:	00c79513          	slli	a0,a5,0xc
  return pa;
    80001088:	bfcd                	j	8000107a <walkaddr+0x2e>
    return 0;
    8000108a:	4501                	li	a0,0
    8000108c:	b7fd                	j	8000107a <walkaddr+0x2e>

000000008000108e <mappages>:
// physical addresses starting at pa. va and size might not
// be page-aligned. Returns 0 on success, -1 if walk() couldn't
// allocate a needed page-table page.
int
mappages(pagetable_t pagetable, uint64 va, uint64 size, uint64 pa, int perm)
{
    8000108e:	715d                	addi	sp,sp,-80
    80001090:	e486                	sd	ra,72(sp)
    80001092:	e0a2                	sd	s0,64(sp)
    80001094:	fc26                	sd	s1,56(sp)
    80001096:	f84a                	sd	s2,48(sp)
    80001098:	f44e                	sd	s3,40(sp)
    8000109a:	f052                	sd	s4,32(sp)
    8000109c:	ec56                	sd	s5,24(sp)
    8000109e:	e85a                	sd	s6,16(sp)
    800010a0:	e45e                	sd	s7,8(sp)
    800010a2:	0880                	addi	s0,sp,80
    800010a4:	8aaa                	mv	s5,a0
    800010a6:	8b3a                	mv	s6,a4
  uint64 a, last;
  pte_t *pte;

  a = PGROUNDDOWN(va);
    800010a8:	777d                	lui	a4,0xfffff
    800010aa:	00e5f7b3          	and	a5,a1,a4
  last = PGROUNDDOWN(va + size - 1);
    800010ae:	fff60993          	addi	s3,a2,-1 # fff <_entry-0x7ffff001>
    800010b2:	99ae                	add	s3,s3,a1
    800010b4:	00e9f9b3          	and	s3,s3,a4
  a = PGROUNDDOWN(va);
    800010b8:	893e                	mv	s2,a5
    800010ba:	40f68a33          	sub	s4,a3,a5
    if(*pte & PTE_V)
      panic("remap");
    *pte = PA2PTE(pa) | perm | PTE_V;
    if(a == last)
      break;
    a += PGSIZE;
    800010be:	6b85                	lui	s7,0x1
    800010c0:	012a04b3          	add	s1,s4,s2
    if((pte = walk(pagetable, a, 1)) == 0)
    800010c4:	4605                	li	a2,1
    800010c6:	85ca                	mv	a1,s2
    800010c8:	8556                	mv	a0,s5
    800010ca:	00000097          	auipc	ra,0x0
    800010ce:	edc080e7          	jalr	-292(ra) # 80000fa6 <walk>
    800010d2:	c51d                	beqz	a0,80001100 <mappages+0x72>
    if(*pte & PTE_V)
    800010d4:	611c                	ld	a5,0(a0)
    800010d6:	8b85                	andi	a5,a5,1
    800010d8:	ef81                	bnez	a5,800010f0 <mappages+0x62>
    *pte = PA2PTE(pa) | perm | PTE_V;
    800010da:	80b1                	srli	s1,s1,0xc
    800010dc:	04aa                	slli	s1,s1,0xa
    800010de:	0164e4b3          	or	s1,s1,s6
    800010e2:	0014e493          	ori	s1,s1,1
    800010e6:	e104                	sd	s1,0(a0)
    if(a == last)
    800010e8:	03390863          	beq	s2,s3,80001118 <mappages+0x8a>
    a += PGSIZE;
    800010ec:	995e                	add	s2,s2,s7
    if((pte = walk(pagetable, a, 1)) == 0)
    800010ee:	bfc9                	j	800010c0 <mappages+0x32>
      panic("remap");
    800010f0:	00007517          	auipc	a0,0x7
    800010f4:	fe850513          	addi	a0,a0,-24 # 800080d8 <digits+0x98>
    800010f8:	fffff097          	auipc	ra,0xfffff
    800010fc:	434080e7          	jalr	1076(ra) # 8000052c <panic>
      return -1;
    80001100:	557d                	li	a0,-1
    pa += PGSIZE;
  }
  return 0;
}
    80001102:	60a6                	ld	ra,72(sp)
    80001104:	6406                	ld	s0,64(sp)
    80001106:	74e2                	ld	s1,56(sp)
    80001108:	7942                	ld	s2,48(sp)
    8000110a:	79a2                	ld	s3,40(sp)
    8000110c:	7a02                	ld	s4,32(sp)
    8000110e:	6ae2                	ld	s5,24(sp)
    80001110:	6b42                	ld	s6,16(sp)
    80001112:	6ba2                	ld	s7,8(sp)
    80001114:	6161                	addi	sp,sp,80
    80001116:	8082                	ret
  return 0;
    80001118:	4501                	li	a0,0
    8000111a:	b7e5                	j	80001102 <mappages+0x74>

000000008000111c <kvmmap>:
{
    8000111c:	1141                	addi	sp,sp,-16
    8000111e:	e406                	sd	ra,8(sp)
    80001120:	e022                	sd	s0,0(sp)
    80001122:	0800                	addi	s0,sp,16
    80001124:	87b6                	mv	a5,a3
  if(mappages(kpgtbl, va, sz, pa, perm) != 0)
    80001126:	86b2                	mv	a3,a2
    80001128:	863e                	mv	a2,a5
    8000112a:	00000097          	auipc	ra,0x0
    8000112e:	f64080e7          	jalr	-156(ra) # 8000108e <mappages>
    80001132:	e509                	bnez	a0,8000113c <kvmmap+0x20>
}
    80001134:	60a2                	ld	ra,8(sp)
    80001136:	6402                	ld	s0,0(sp)
    80001138:	0141                	addi	sp,sp,16
    8000113a:	8082                	ret
    panic("kvmmap");
    8000113c:	00007517          	auipc	a0,0x7
    80001140:	fa450513          	addi	a0,a0,-92 # 800080e0 <digits+0xa0>
    80001144:	fffff097          	auipc	ra,0xfffff
    80001148:	3e8080e7          	jalr	1000(ra) # 8000052c <panic>

000000008000114c <kvmmake>:
{
    8000114c:	1101                	addi	sp,sp,-32
    8000114e:	ec06                	sd	ra,24(sp)
    80001150:	e822                	sd	s0,16(sp)
    80001152:	e426                	sd	s1,8(sp)
    80001154:	e04a                	sd	s2,0(sp)
    80001156:	1000                	addi	s0,sp,32
  kpgtbl = (pagetable_t) kalloc();
    80001158:	00000097          	auipc	ra,0x0
    8000115c:	97a080e7          	jalr	-1670(ra) # 80000ad2 <kalloc>
    80001160:	84aa                	mv	s1,a0
  memset(kpgtbl, 0, PGSIZE);
    80001162:	6605                	lui	a2,0x1
    80001164:	4581                	li	a1,0
    80001166:	00000097          	auipc	ra,0x0
    8000116a:	b58080e7          	jalr	-1192(ra) # 80000cbe <memset>
  kvmmap(kpgtbl, UART0, UART0, PGSIZE, PTE_R | PTE_W);
    8000116e:	4719                	li	a4,6
    80001170:	6685                	lui	a3,0x1
    80001172:	10000637          	lui	a2,0x10000
    80001176:	100005b7          	lui	a1,0x10000
    8000117a:	8526                	mv	a0,s1
    8000117c:	00000097          	auipc	ra,0x0
    80001180:	fa0080e7          	jalr	-96(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, VIRTIO0, VIRTIO0, PGSIZE, PTE_R | PTE_W);
    80001184:	4719                	li	a4,6
    80001186:	6685                	lui	a3,0x1
    80001188:	10001637          	lui	a2,0x10001
    8000118c:	100015b7          	lui	a1,0x10001
    80001190:	8526                	mv	a0,s1
    80001192:	00000097          	auipc	ra,0x0
    80001196:	f8a080e7          	jalr	-118(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, PLIC, PLIC, 0x400000, PTE_R | PTE_W);
    8000119a:	4719                	li	a4,6
    8000119c:	004006b7          	lui	a3,0x400
    800011a0:	0c000637          	lui	a2,0xc000
    800011a4:	0c0005b7          	lui	a1,0xc000
    800011a8:	8526                	mv	a0,s1
    800011aa:	00000097          	auipc	ra,0x0
    800011ae:	f72080e7          	jalr	-142(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);
    800011b2:	00007917          	auipc	s2,0x7
    800011b6:	e4e90913          	addi	s2,s2,-434 # 80008000 <etext>
    800011ba:	4729                	li	a4,10
    800011bc:	80007697          	auipc	a3,0x80007
    800011c0:	e4468693          	addi	a3,a3,-444 # 8000 <_entry-0x7fff8000>
    800011c4:	4605                	li	a2,1
    800011c6:	067e                	slli	a2,a2,0x1f
    800011c8:	85b2                	mv	a1,a2
    800011ca:	8526                	mv	a0,s1
    800011cc:	00000097          	auipc	ra,0x0
    800011d0:	f50080e7          	jalr	-176(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, (uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);
    800011d4:	4719                	li	a4,6
    800011d6:	46c5                	li	a3,17
    800011d8:	06ee                	slli	a3,a3,0x1b
    800011da:	412686b3          	sub	a3,a3,s2
    800011de:	864a                	mv	a2,s2
    800011e0:	85ca                	mv	a1,s2
    800011e2:	8526                	mv	a0,s1
    800011e4:	00000097          	auipc	ra,0x0
    800011e8:	f38080e7          	jalr	-200(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
    800011ec:	4729                	li	a4,10
    800011ee:	6685                	lui	a3,0x1
    800011f0:	00006617          	auipc	a2,0x6
    800011f4:	e1060613          	addi	a2,a2,-496 # 80007000 <_trampoline>
    800011f8:	040005b7          	lui	a1,0x4000
    800011fc:	15fd                	addi	a1,a1,-1 # 3ffffff <_entry-0x7c000001>
    800011fe:	05b2                	slli	a1,a1,0xc
    80001200:	8526                	mv	a0,s1
    80001202:	00000097          	auipc	ra,0x0
    80001206:	f1a080e7          	jalr	-230(ra) # 8000111c <kvmmap>
  proc_mapstacks(kpgtbl);
    8000120a:	8526                	mv	a0,s1
    8000120c:	00000097          	auipc	ra,0x0
    80001210:	644080e7          	jalr	1604(ra) # 80001850 <proc_mapstacks>
}
    80001214:	8526                	mv	a0,s1
    80001216:	60e2                	ld	ra,24(sp)
    80001218:	6442                	ld	s0,16(sp)
    8000121a:	64a2                	ld	s1,8(sp)
    8000121c:	6902                	ld	s2,0(sp)
    8000121e:	6105                	addi	sp,sp,32
    80001220:	8082                	ret

0000000080001222 <kvminit>:
{
    80001222:	1141                	addi	sp,sp,-16
    80001224:	e406                	sd	ra,8(sp)
    80001226:	e022                	sd	s0,0(sp)
    80001228:	0800                	addi	s0,sp,16
  kernel_pagetable = kvmmake();
    8000122a:	00000097          	auipc	ra,0x0
    8000122e:	f22080e7          	jalr	-222(ra) # 8000114c <kvmmake>
    80001232:	00008797          	auipc	a5,0x8
    80001236:	dea7b723          	sd	a0,-530(a5) # 80009020 <kernel_pagetable>
}
    8000123a:	60a2                	ld	ra,8(sp)
    8000123c:	6402                	ld	s0,0(sp)
    8000123e:	0141                	addi	sp,sp,16
    80001240:	8082                	ret

0000000080001242 <uvmunmap>:
// Remove npages of mappings starting from va. va must be
// page-aligned. The mappings must exist.
// Optionally free the physical memory.
void
uvmunmap(pagetable_t pagetable, uint64 va, uint64 npages, int do_free)
{
    80001242:	715d                	addi	sp,sp,-80
    80001244:	e486                	sd	ra,72(sp)
    80001246:	e0a2                	sd	s0,64(sp)
    80001248:	fc26                	sd	s1,56(sp)
    8000124a:	f84a                	sd	s2,48(sp)
    8000124c:	f44e                	sd	s3,40(sp)
    8000124e:	f052                	sd	s4,32(sp)
    80001250:	ec56                	sd	s5,24(sp)
    80001252:	e85a                	sd	s6,16(sp)
    80001254:	e45e                	sd	s7,8(sp)
    80001256:	0880                	addi	s0,sp,80
  uint64 a;
  pte_t *pte;

  if((va % PGSIZE) != 0)
    80001258:	03459793          	slli	a5,a1,0x34
    8000125c:	e795                	bnez	a5,80001288 <uvmunmap+0x46>
    8000125e:	8a2a                	mv	s4,a0
    80001260:	892e                	mv	s2,a1
    80001262:	8ab6                	mv	s5,a3
    panic("uvmunmap: not aligned");

  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    80001264:	0632                	slli	a2,a2,0xc
    80001266:	00b609b3          	add	s3,a2,a1
    if((pte = walk(pagetable, a, 0)) == 0)
      panic("uvmunmap: walk");
    if((*pte & PTE_V) == 0)
      panic("uvmunmap: not mapped");
    if(PTE_FLAGS(*pte) == PTE_V)
    8000126a:	4b85                	li	s7,1
  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    8000126c:	6b05                	lui	s6,0x1
    8000126e:	0735e263          	bltu	a1,s3,800012d2 <uvmunmap+0x90>
      uint64 pa = PTE2PA(*pte);
      kfree((void*)pa);
    }
    *pte = 0;
  }
}
    80001272:	60a6                	ld	ra,72(sp)
    80001274:	6406                	ld	s0,64(sp)
    80001276:	74e2                	ld	s1,56(sp)
    80001278:	7942                	ld	s2,48(sp)
    8000127a:	79a2                	ld	s3,40(sp)
    8000127c:	7a02                	ld	s4,32(sp)
    8000127e:	6ae2                	ld	s5,24(sp)
    80001280:	6b42                	ld	s6,16(sp)
    80001282:	6ba2                	ld	s7,8(sp)
    80001284:	6161                	addi	sp,sp,80
    80001286:	8082                	ret
    panic("uvmunmap: not aligned");
    80001288:	00007517          	auipc	a0,0x7
    8000128c:	e6050513          	addi	a0,a0,-416 # 800080e8 <digits+0xa8>
    80001290:	fffff097          	auipc	ra,0xfffff
    80001294:	29c080e7          	jalr	668(ra) # 8000052c <panic>
      panic("uvmunmap: walk");
    80001298:	00007517          	auipc	a0,0x7
    8000129c:	e6850513          	addi	a0,a0,-408 # 80008100 <digits+0xc0>
    800012a0:	fffff097          	auipc	ra,0xfffff
    800012a4:	28c080e7          	jalr	652(ra) # 8000052c <panic>
      panic("uvmunmap: not mapped");
    800012a8:	00007517          	auipc	a0,0x7
    800012ac:	e6850513          	addi	a0,a0,-408 # 80008110 <digits+0xd0>
    800012b0:	fffff097          	auipc	ra,0xfffff
    800012b4:	27c080e7          	jalr	636(ra) # 8000052c <panic>
      panic("uvmunmap: not a leaf");
    800012b8:	00007517          	auipc	a0,0x7
    800012bc:	e7050513          	addi	a0,a0,-400 # 80008128 <digits+0xe8>
    800012c0:	fffff097          	auipc	ra,0xfffff
    800012c4:	26c080e7          	jalr	620(ra) # 8000052c <panic>
    *pte = 0;
    800012c8:	0004b023          	sd	zero,0(s1)
  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    800012cc:	995a                	add	s2,s2,s6
    800012ce:	fb3972e3          	bgeu	s2,s3,80001272 <uvmunmap+0x30>
    if((pte = walk(pagetable, a, 0)) == 0)
    800012d2:	4601                	li	a2,0
    800012d4:	85ca                	mv	a1,s2
    800012d6:	8552                	mv	a0,s4
    800012d8:	00000097          	auipc	ra,0x0
    800012dc:	cce080e7          	jalr	-818(ra) # 80000fa6 <walk>
    800012e0:	84aa                	mv	s1,a0
    800012e2:	d95d                	beqz	a0,80001298 <uvmunmap+0x56>
    if((*pte & PTE_V) == 0)
    800012e4:	6108                	ld	a0,0(a0)
    800012e6:	00157793          	andi	a5,a0,1
    800012ea:	dfdd                	beqz	a5,800012a8 <uvmunmap+0x66>
    if(PTE_FLAGS(*pte) == PTE_V)
    800012ec:	3ff57793          	andi	a5,a0,1023
    800012f0:	fd7784e3          	beq	a5,s7,800012b8 <uvmunmap+0x76>
    if(do_free){
    800012f4:	fc0a8ae3          	beqz	s5,800012c8 <uvmunmap+0x86>
      uint64 pa = PTE2PA(*pte);
    800012f8:	8129                	srli	a0,a0,0xa
      kfree((void*)pa);
    800012fa:	0532                	slli	a0,a0,0xc
    800012fc:	fffff097          	auipc	ra,0xfffff
    80001300:	6d8080e7          	jalr	1752(ra) # 800009d4 <kfree>
    80001304:	b7d1                	j	800012c8 <uvmunmap+0x86>

0000000080001306 <uvmcreate>:

// create an empty user page table.
// returns 0 if out of memory.
pagetable_t
uvmcreate()
{
    80001306:	1101                	addi	sp,sp,-32
    80001308:	ec06                	sd	ra,24(sp)
    8000130a:	e822                	sd	s0,16(sp)
    8000130c:	e426                	sd	s1,8(sp)
    8000130e:	1000                	addi	s0,sp,32
  pagetable_t pagetable;
  pagetable = (pagetable_t) kalloc();
    80001310:	fffff097          	auipc	ra,0xfffff
    80001314:	7c2080e7          	jalr	1986(ra) # 80000ad2 <kalloc>
    80001318:	84aa                	mv	s1,a0
  if(pagetable == 0)
    8000131a:	c519                	beqz	a0,80001328 <uvmcreate+0x22>
    return 0;
  memset(pagetable, 0, PGSIZE);
    8000131c:	6605                	lui	a2,0x1
    8000131e:	4581                	li	a1,0
    80001320:	00000097          	auipc	ra,0x0
    80001324:	99e080e7          	jalr	-1634(ra) # 80000cbe <memset>
  return pagetable;
}
    80001328:	8526                	mv	a0,s1
    8000132a:	60e2                	ld	ra,24(sp)
    8000132c:	6442                	ld	s0,16(sp)
    8000132e:	64a2                	ld	s1,8(sp)
    80001330:	6105                	addi	sp,sp,32
    80001332:	8082                	ret

0000000080001334 <uvminit>:
// Load the user initcode into address 0 of pagetable,
// for the very first process.
// sz must be less than a page.
void
uvminit(pagetable_t pagetable, uchar *src, uint sz)
{
    80001334:	7179                	addi	sp,sp,-48
    80001336:	f406                	sd	ra,40(sp)
    80001338:	f022                	sd	s0,32(sp)
    8000133a:	ec26                	sd	s1,24(sp)
    8000133c:	e84a                	sd	s2,16(sp)
    8000133e:	e44e                	sd	s3,8(sp)
    80001340:	e052                	sd	s4,0(sp)
    80001342:	1800                	addi	s0,sp,48
  char *mem;

  if(sz >= PGSIZE)
    80001344:	6785                	lui	a5,0x1
    80001346:	04f67863          	bgeu	a2,a5,80001396 <uvminit+0x62>
    8000134a:	8a2a                	mv	s4,a0
    8000134c:	89ae                	mv	s3,a1
    8000134e:	84b2                	mv	s1,a2
    panic("inituvm: more than a page");
  mem = kalloc();
    80001350:	fffff097          	auipc	ra,0xfffff
    80001354:	782080e7          	jalr	1922(ra) # 80000ad2 <kalloc>
    80001358:	892a                	mv	s2,a0
  memset(mem, 0, PGSIZE);
    8000135a:	6605                	lui	a2,0x1
    8000135c:	4581                	li	a1,0
    8000135e:	00000097          	auipc	ra,0x0
    80001362:	960080e7          	jalr	-1696(ra) # 80000cbe <memset>
  mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);
    80001366:	4779                	li	a4,30
    80001368:	86ca                	mv	a3,s2
    8000136a:	6605                	lui	a2,0x1
    8000136c:	4581                	li	a1,0
    8000136e:	8552                	mv	a0,s4
    80001370:	00000097          	auipc	ra,0x0
    80001374:	d1e080e7          	jalr	-738(ra) # 8000108e <mappages>
  memmove(mem, src, sz);
    80001378:	8626                	mv	a2,s1
    8000137a:	85ce                	mv	a1,s3
    8000137c:	854a                	mv	a0,s2
    8000137e:	00000097          	auipc	ra,0x0
    80001382:	99c080e7          	jalr	-1636(ra) # 80000d1a <memmove>
}
    80001386:	70a2                	ld	ra,40(sp)
    80001388:	7402                	ld	s0,32(sp)
    8000138a:	64e2                	ld	s1,24(sp)
    8000138c:	6942                	ld	s2,16(sp)
    8000138e:	69a2                	ld	s3,8(sp)
    80001390:	6a02                	ld	s4,0(sp)
    80001392:	6145                	addi	sp,sp,48
    80001394:	8082                	ret
    panic("inituvm: more than a page");
    80001396:	00007517          	auipc	a0,0x7
    8000139a:	daa50513          	addi	a0,a0,-598 # 80008140 <digits+0x100>
    8000139e:	fffff097          	auipc	ra,0xfffff
    800013a2:	18e080e7          	jalr	398(ra) # 8000052c <panic>

00000000800013a6 <uvmdealloc>:
// newsz.  oldsz and newsz need not be page-aligned, nor does newsz
// need to be less than oldsz.  oldsz can be larger than the actual
// process size.  Returns the new process size.
uint64
uvmdealloc(pagetable_t pagetable, uint64 oldsz, uint64 newsz)
{
    800013a6:	1101                	addi	sp,sp,-32
    800013a8:	ec06                	sd	ra,24(sp)
    800013aa:	e822                	sd	s0,16(sp)
    800013ac:	e426                	sd	s1,8(sp)
    800013ae:	1000                	addi	s0,sp,32
  if(newsz >= oldsz)
    return oldsz;
    800013b0:	84ae                	mv	s1,a1
  if(newsz >= oldsz)
    800013b2:	00b67d63          	bgeu	a2,a1,800013cc <uvmdealloc+0x26>
    800013b6:	84b2                	mv	s1,a2

  if(PGROUNDUP(newsz) < PGROUNDUP(oldsz)){
    800013b8:	6785                	lui	a5,0x1
    800013ba:	17fd                	addi	a5,a5,-1 # fff <_entry-0x7ffff001>
    800013bc:	00f60733          	add	a4,a2,a5
    800013c0:	76fd                	lui	a3,0xfffff
    800013c2:	8f75                	and	a4,a4,a3
    800013c4:	97ae                	add	a5,a5,a1
    800013c6:	8ff5                	and	a5,a5,a3
    800013c8:	00f76863          	bltu	a4,a5,800013d8 <uvmdealloc+0x32>
    int npages = (PGROUNDUP(oldsz) - PGROUNDUP(newsz)) / PGSIZE;
    uvmunmap(pagetable, PGROUNDUP(newsz), npages, 1);
  }

  return newsz;
}
    800013cc:	8526                	mv	a0,s1
    800013ce:	60e2                	ld	ra,24(sp)
    800013d0:	6442                	ld	s0,16(sp)
    800013d2:	64a2                	ld	s1,8(sp)
    800013d4:	6105                	addi	sp,sp,32
    800013d6:	8082                	ret
    int npages = (PGROUNDUP(oldsz) - PGROUNDUP(newsz)) / PGSIZE;
    800013d8:	8f99                	sub	a5,a5,a4
    800013da:	83b1                	srli	a5,a5,0xc
    uvmunmap(pagetable, PGROUNDUP(newsz), npages, 1);
    800013dc:	4685                	li	a3,1
    800013de:	0007861b          	sext.w	a2,a5
    800013e2:	85ba                	mv	a1,a4
    800013e4:	00000097          	auipc	ra,0x0
    800013e8:	e5e080e7          	jalr	-418(ra) # 80001242 <uvmunmap>
    800013ec:	b7c5                	j	800013cc <uvmdealloc+0x26>

00000000800013ee <uvmalloc>:
  if(newsz < oldsz)
    800013ee:	0ab66163          	bltu	a2,a1,80001490 <uvmalloc+0xa2>
{
    800013f2:	7139                	addi	sp,sp,-64
    800013f4:	fc06                	sd	ra,56(sp)
    800013f6:	f822                	sd	s0,48(sp)
    800013f8:	f426                	sd	s1,40(sp)
    800013fa:	f04a                	sd	s2,32(sp)
    800013fc:	ec4e                	sd	s3,24(sp)
    800013fe:	e852                	sd	s4,16(sp)
    80001400:	e456                	sd	s5,8(sp)
    80001402:	0080                	addi	s0,sp,64
    80001404:	8aaa                	mv	s5,a0
    80001406:	8a32                	mv	s4,a2
  oldsz = PGROUNDUP(oldsz);
    80001408:	6785                	lui	a5,0x1
    8000140a:	17fd                	addi	a5,a5,-1 # fff <_entry-0x7ffff001>
    8000140c:	95be                	add	a1,a1,a5
    8000140e:	77fd                	lui	a5,0xfffff
    80001410:	00f5f9b3          	and	s3,a1,a5
  for(a = oldsz; a < newsz; a += PGSIZE){
    80001414:	08c9f063          	bgeu	s3,a2,80001494 <uvmalloc+0xa6>
    80001418:	894e                	mv	s2,s3
    mem = kalloc();
    8000141a:	fffff097          	auipc	ra,0xfffff
    8000141e:	6b8080e7          	jalr	1720(ra) # 80000ad2 <kalloc>
    80001422:	84aa                	mv	s1,a0
    if(mem == 0){
    80001424:	c51d                	beqz	a0,80001452 <uvmalloc+0x64>
    memset(mem, 0, PGSIZE);
    80001426:	6605                	lui	a2,0x1
    80001428:	4581                	li	a1,0
    8000142a:	00000097          	auipc	ra,0x0
    8000142e:	894080e7          	jalr	-1900(ra) # 80000cbe <memset>
    if(mappages(pagetable, a, PGSIZE, (uint64)mem, PTE_W|PTE_X|PTE_R|PTE_U) != 0){
    80001432:	4779                	li	a4,30
    80001434:	86a6                	mv	a3,s1
    80001436:	6605                	lui	a2,0x1
    80001438:	85ca                	mv	a1,s2
    8000143a:	8556                	mv	a0,s5
    8000143c:	00000097          	auipc	ra,0x0
    80001440:	c52080e7          	jalr	-942(ra) # 8000108e <mappages>
    80001444:	e905                	bnez	a0,80001474 <uvmalloc+0x86>
  for(a = oldsz; a < newsz; a += PGSIZE){
    80001446:	6785                	lui	a5,0x1
    80001448:	993e                	add	s2,s2,a5
    8000144a:	fd4968e3          	bltu	s2,s4,8000141a <uvmalloc+0x2c>
  return newsz;
    8000144e:	8552                	mv	a0,s4
    80001450:	a809                	j	80001462 <uvmalloc+0x74>
      uvmdealloc(pagetable, a, oldsz);
    80001452:	864e                	mv	a2,s3
    80001454:	85ca                	mv	a1,s2
    80001456:	8556                	mv	a0,s5
    80001458:	00000097          	auipc	ra,0x0
    8000145c:	f4e080e7          	jalr	-178(ra) # 800013a6 <uvmdealloc>
      return 0;
    80001460:	4501                	li	a0,0
}
    80001462:	70e2                	ld	ra,56(sp)
    80001464:	7442                	ld	s0,48(sp)
    80001466:	74a2                	ld	s1,40(sp)
    80001468:	7902                	ld	s2,32(sp)
    8000146a:	69e2                	ld	s3,24(sp)
    8000146c:	6a42                	ld	s4,16(sp)
    8000146e:	6aa2                	ld	s5,8(sp)
    80001470:	6121                	addi	sp,sp,64
    80001472:	8082                	ret
      kfree(mem);
    80001474:	8526                	mv	a0,s1
    80001476:	fffff097          	auipc	ra,0xfffff
    8000147a:	55e080e7          	jalr	1374(ra) # 800009d4 <kfree>
      uvmdealloc(pagetable, a, oldsz);
    8000147e:	864e                	mv	a2,s3
    80001480:	85ca                	mv	a1,s2
    80001482:	8556                	mv	a0,s5
    80001484:	00000097          	auipc	ra,0x0
    80001488:	f22080e7          	jalr	-222(ra) # 800013a6 <uvmdealloc>
      return 0;
    8000148c:	4501                	li	a0,0
    8000148e:	bfd1                	j	80001462 <uvmalloc+0x74>
    return oldsz;
    80001490:	852e                	mv	a0,a1
}
    80001492:	8082                	ret
  return newsz;
    80001494:	8532                	mv	a0,a2
    80001496:	b7f1                	j	80001462 <uvmalloc+0x74>

0000000080001498 <freewalk>:

// Recursively free page-table pages.
// All leaf mappings must already have been removed.
void
freewalk(pagetable_t pagetable)
{
    80001498:	7179                	addi	sp,sp,-48
    8000149a:	f406                	sd	ra,40(sp)
    8000149c:	f022                	sd	s0,32(sp)
    8000149e:	ec26                	sd	s1,24(sp)
    800014a0:	e84a                	sd	s2,16(sp)
    800014a2:	e44e                	sd	s3,8(sp)
    800014a4:	e052                	sd	s4,0(sp)
    800014a6:	1800                	addi	s0,sp,48
    800014a8:	8a2a                	mv	s4,a0
  // there are 2^9 = 512 PTEs in a page table.
  for(int i = 0; i < 512; i++){
    800014aa:	84aa                	mv	s1,a0
    800014ac:	6905                	lui	s2,0x1
    800014ae:	992a                	add	s2,s2,a0
    pte_t pte = pagetable[i];
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    800014b0:	4985                	li	s3,1
    800014b2:	a829                	j	800014cc <freewalk+0x34>
      // this PTE points to a lower-level page table.
      uint64 child = PTE2PA(pte);
    800014b4:	83a9                	srli	a5,a5,0xa
      freewalk((pagetable_t)child);
    800014b6:	00c79513          	slli	a0,a5,0xc
    800014ba:	00000097          	auipc	ra,0x0
    800014be:	fde080e7          	jalr	-34(ra) # 80001498 <freewalk>
      pagetable[i] = 0;
    800014c2:	0004b023          	sd	zero,0(s1)
  for(int i = 0; i < 512; i++){
    800014c6:	04a1                	addi	s1,s1,8
    800014c8:	03248163          	beq	s1,s2,800014ea <freewalk+0x52>
    pte_t pte = pagetable[i];
    800014cc:	609c                	ld	a5,0(s1)
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    800014ce:	00f7f713          	andi	a4,a5,15
    800014d2:	ff3701e3          	beq	a4,s3,800014b4 <freewalk+0x1c>
    } else if(pte & PTE_V){
    800014d6:	8b85                	andi	a5,a5,1
    800014d8:	d7fd                	beqz	a5,800014c6 <freewalk+0x2e>
      panic("freewalk: leaf");
    800014da:	00007517          	auipc	a0,0x7
    800014de:	c8650513          	addi	a0,a0,-890 # 80008160 <digits+0x120>
    800014e2:	fffff097          	auipc	ra,0xfffff
    800014e6:	04a080e7          	jalr	74(ra) # 8000052c <panic>
    }
  }
  kfree((void*)pagetable);
    800014ea:	8552                	mv	a0,s4
    800014ec:	fffff097          	auipc	ra,0xfffff
    800014f0:	4e8080e7          	jalr	1256(ra) # 800009d4 <kfree>
}
    800014f4:	70a2                	ld	ra,40(sp)
    800014f6:	7402                	ld	s0,32(sp)
    800014f8:	64e2                	ld	s1,24(sp)
    800014fa:	6942                	ld	s2,16(sp)
    800014fc:	69a2                	ld	s3,8(sp)
    800014fe:	6a02                	ld	s4,0(sp)
    80001500:	6145                	addi	sp,sp,48
    80001502:	8082                	ret

0000000080001504 <uvmfree>:

// Free user memory pages,
// then free page-table pages.
void
uvmfree(pagetable_t pagetable, uint64 sz)
{
    80001504:	1101                	addi	sp,sp,-32
    80001506:	ec06                	sd	ra,24(sp)
    80001508:	e822                	sd	s0,16(sp)
    8000150a:	e426                	sd	s1,8(sp)
    8000150c:	1000                	addi	s0,sp,32
    8000150e:	84aa                	mv	s1,a0
  if(sz > 0)
    80001510:	e999                	bnez	a1,80001526 <uvmfree+0x22>
    uvmunmap(pagetable, 0, PGROUNDUP(sz)/PGSIZE, 1);
  freewalk(pagetable);
    80001512:	8526                	mv	a0,s1
    80001514:	00000097          	auipc	ra,0x0
    80001518:	f84080e7          	jalr	-124(ra) # 80001498 <freewalk>
}
    8000151c:	60e2                	ld	ra,24(sp)
    8000151e:	6442                	ld	s0,16(sp)
    80001520:	64a2                	ld	s1,8(sp)
    80001522:	6105                	addi	sp,sp,32
    80001524:	8082                	ret
    uvmunmap(pagetable, 0, PGROUNDUP(sz)/PGSIZE, 1);
    80001526:	6785                	lui	a5,0x1
    80001528:	17fd                	addi	a5,a5,-1 # fff <_entry-0x7ffff001>
    8000152a:	95be                	add	a1,a1,a5
    8000152c:	4685                	li	a3,1
    8000152e:	00c5d613          	srli	a2,a1,0xc
    80001532:	4581                	li	a1,0
    80001534:	00000097          	auipc	ra,0x0
    80001538:	d0e080e7          	jalr	-754(ra) # 80001242 <uvmunmap>
    8000153c:	bfd9                	j	80001512 <uvmfree+0xe>

000000008000153e <uvmcopy>:
  pte_t *pte;
  uint64 pa, i;
  uint flags;
  char *mem;

  for(i = 0; i < sz; i += PGSIZE){
    8000153e:	c679                	beqz	a2,8000160c <uvmcopy+0xce>
{
    80001540:	715d                	addi	sp,sp,-80
    80001542:	e486                	sd	ra,72(sp)
    80001544:	e0a2                	sd	s0,64(sp)
    80001546:	fc26                	sd	s1,56(sp)
    80001548:	f84a                	sd	s2,48(sp)
    8000154a:	f44e                	sd	s3,40(sp)
    8000154c:	f052                	sd	s4,32(sp)
    8000154e:	ec56                	sd	s5,24(sp)
    80001550:	e85a                	sd	s6,16(sp)
    80001552:	e45e                	sd	s7,8(sp)
    80001554:	0880                	addi	s0,sp,80
    80001556:	8b2a                	mv	s6,a0
    80001558:	8aae                	mv	s5,a1
    8000155a:	8a32                	mv	s4,a2
  for(i = 0; i < sz; i += PGSIZE){
    8000155c:	4981                	li	s3,0
    if((pte = walk(old, i, 0)) == 0)
    8000155e:	4601                	li	a2,0
    80001560:	85ce                	mv	a1,s3
    80001562:	855a                	mv	a0,s6
    80001564:	00000097          	auipc	ra,0x0
    80001568:	a42080e7          	jalr	-1470(ra) # 80000fa6 <walk>
    8000156c:	c531                	beqz	a0,800015b8 <uvmcopy+0x7a>
      panic("uvmcopy: pte should exist");
    if((*pte & PTE_V) == 0)
    8000156e:	6118                	ld	a4,0(a0)
    80001570:	00177793          	andi	a5,a4,1
    80001574:	cbb1                	beqz	a5,800015c8 <uvmcopy+0x8a>
      panic("uvmcopy: page not present");
    pa = PTE2PA(*pte);
    80001576:	00a75593          	srli	a1,a4,0xa
    8000157a:	00c59b93          	slli	s7,a1,0xc
    flags = PTE_FLAGS(*pte);
    8000157e:	3ff77493          	andi	s1,a4,1023
    if((mem = kalloc()) == 0)
    80001582:	fffff097          	auipc	ra,0xfffff
    80001586:	550080e7          	jalr	1360(ra) # 80000ad2 <kalloc>
    8000158a:	892a                	mv	s2,a0
    8000158c:	c939                	beqz	a0,800015e2 <uvmcopy+0xa4>
      goto err;
    memmove(mem, (char*)pa, PGSIZE);
    8000158e:	6605                	lui	a2,0x1
    80001590:	85de                	mv	a1,s7
    80001592:	fffff097          	auipc	ra,0xfffff
    80001596:	788080e7          	jalr	1928(ra) # 80000d1a <memmove>
    if(mappages(new, i, PGSIZE, (uint64)mem, flags) != 0){
    8000159a:	8726                	mv	a4,s1
    8000159c:	86ca                	mv	a3,s2
    8000159e:	6605                	lui	a2,0x1
    800015a0:	85ce                	mv	a1,s3
    800015a2:	8556                	mv	a0,s5
    800015a4:	00000097          	auipc	ra,0x0
    800015a8:	aea080e7          	jalr	-1302(ra) # 8000108e <mappages>
    800015ac:	e515                	bnez	a0,800015d8 <uvmcopy+0x9a>
  for(i = 0; i < sz; i += PGSIZE){
    800015ae:	6785                	lui	a5,0x1
    800015b0:	99be                	add	s3,s3,a5
    800015b2:	fb49e6e3          	bltu	s3,s4,8000155e <uvmcopy+0x20>
    800015b6:	a081                	j	800015f6 <uvmcopy+0xb8>
      panic("uvmcopy: pte should exist");
    800015b8:	00007517          	auipc	a0,0x7
    800015bc:	bb850513          	addi	a0,a0,-1096 # 80008170 <digits+0x130>
    800015c0:	fffff097          	auipc	ra,0xfffff
    800015c4:	f6c080e7          	jalr	-148(ra) # 8000052c <panic>
      panic("uvmcopy: page not present");
    800015c8:	00007517          	auipc	a0,0x7
    800015cc:	bc850513          	addi	a0,a0,-1080 # 80008190 <digits+0x150>
    800015d0:	fffff097          	auipc	ra,0xfffff
    800015d4:	f5c080e7          	jalr	-164(ra) # 8000052c <panic>
      kfree(mem);
    800015d8:	854a                	mv	a0,s2
    800015da:	fffff097          	auipc	ra,0xfffff
    800015de:	3fa080e7          	jalr	1018(ra) # 800009d4 <kfree>
    }
  }
  return 0;

 err:
  uvmunmap(new, 0, i / PGSIZE, 1);
    800015e2:	4685                	li	a3,1
    800015e4:	00c9d613          	srli	a2,s3,0xc
    800015e8:	4581                	li	a1,0
    800015ea:	8556                	mv	a0,s5
    800015ec:	00000097          	auipc	ra,0x0
    800015f0:	c56080e7          	jalr	-938(ra) # 80001242 <uvmunmap>
  return -1;
    800015f4:	557d                	li	a0,-1
}
    800015f6:	60a6                	ld	ra,72(sp)
    800015f8:	6406                	ld	s0,64(sp)
    800015fa:	74e2                	ld	s1,56(sp)
    800015fc:	7942                	ld	s2,48(sp)
    800015fe:	79a2                	ld	s3,40(sp)
    80001600:	7a02                	ld	s4,32(sp)
    80001602:	6ae2                	ld	s5,24(sp)
    80001604:	6b42                	ld	s6,16(sp)
    80001606:	6ba2                	ld	s7,8(sp)
    80001608:	6161                	addi	sp,sp,80
    8000160a:	8082                	ret
  return 0;
    8000160c:	4501                	li	a0,0
}
    8000160e:	8082                	ret

0000000080001610 <uvmclear>:

// mark a PTE invalid for user access.
// used by exec for the user stack guard page.
void
uvmclear(pagetable_t pagetable, uint64 va)
{
    80001610:	1141                	addi	sp,sp,-16
    80001612:	e406                	sd	ra,8(sp)
    80001614:	e022                	sd	s0,0(sp)
    80001616:	0800                	addi	s0,sp,16
  pte_t *pte;
  
  pte = walk(pagetable, va, 0);
    80001618:	4601                	li	a2,0
    8000161a:	00000097          	auipc	ra,0x0
    8000161e:	98c080e7          	jalr	-1652(ra) # 80000fa6 <walk>
  if(pte == 0)
    80001622:	c901                	beqz	a0,80001632 <uvmclear+0x22>
    panic("uvmclear");
  *pte &= ~PTE_U;
    80001624:	611c                	ld	a5,0(a0)
    80001626:	9bbd                	andi	a5,a5,-17
    80001628:	e11c                	sd	a5,0(a0)
}
    8000162a:	60a2                	ld	ra,8(sp)
    8000162c:	6402                	ld	s0,0(sp)
    8000162e:	0141                	addi	sp,sp,16
    80001630:	8082                	ret
    panic("uvmclear");
    80001632:	00007517          	auipc	a0,0x7
    80001636:	b7e50513          	addi	a0,a0,-1154 # 800081b0 <digits+0x170>
    8000163a:	fffff097          	auipc	ra,0xfffff
    8000163e:	ef2080e7          	jalr	-270(ra) # 8000052c <panic>

0000000080001642 <copyout>:
int
copyout(pagetable_t pagetable, uint64 dstva, char *src, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    80001642:	c6bd                	beqz	a3,800016b0 <copyout+0x6e>
{
    80001644:	715d                	addi	sp,sp,-80
    80001646:	e486                	sd	ra,72(sp)
    80001648:	e0a2                	sd	s0,64(sp)
    8000164a:	fc26                	sd	s1,56(sp)
    8000164c:	f84a                	sd	s2,48(sp)
    8000164e:	f44e                	sd	s3,40(sp)
    80001650:	f052                	sd	s4,32(sp)
    80001652:	ec56                	sd	s5,24(sp)
    80001654:	e85a                	sd	s6,16(sp)
    80001656:	e45e                	sd	s7,8(sp)
    80001658:	e062                	sd	s8,0(sp)
    8000165a:	0880                	addi	s0,sp,80
    8000165c:	8b2a                	mv	s6,a0
    8000165e:	8c2e                	mv	s8,a1
    80001660:	8a32                	mv	s4,a2
    80001662:	89b6                	mv	s3,a3
    va0 = PGROUNDDOWN(dstva);
    80001664:	7bfd                	lui	s7,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (dstva - va0);
    80001666:	6a85                	lui	s5,0x1
    80001668:	a015                	j	8000168c <copyout+0x4a>
    if(n > len)
      n = len;
    memmove((void *)(pa0 + (dstva - va0)), src, n);
    8000166a:	9562                	add	a0,a0,s8
    8000166c:	0004861b          	sext.w	a2,s1
    80001670:	85d2                	mv	a1,s4
    80001672:	41250533          	sub	a0,a0,s2
    80001676:	fffff097          	auipc	ra,0xfffff
    8000167a:	6a4080e7          	jalr	1700(ra) # 80000d1a <memmove>

    len -= n;
    8000167e:	409989b3          	sub	s3,s3,s1
    src += n;
    80001682:	9a26                	add	s4,s4,s1
    dstva = va0 + PGSIZE;
    80001684:	01590c33          	add	s8,s2,s5
  while(len > 0){
    80001688:	02098263          	beqz	s3,800016ac <copyout+0x6a>
    va0 = PGROUNDDOWN(dstva);
    8000168c:	017c7933          	and	s2,s8,s7
    pa0 = walkaddr(pagetable, va0);
    80001690:	85ca                	mv	a1,s2
    80001692:	855a                	mv	a0,s6
    80001694:	00000097          	auipc	ra,0x0
    80001698:	9b8080e7          	jalr	-1608(ra) # 8000104c <walkaddr>
    if(pa0 == 0)
    8000169c:	cd01                	beqz	a0,800016b4 <copyout+0x72>
    n = PGSIZE - (dstva - va0);
    8000169e:	418904b3          	sub	s1,s2,s8
    800016a2:	94d6                	add	s1,s1,s5
    800016a4:	fc99f3e3          	bgeu	s3,s1,8000166a <copyout+0x28>
    800016a8:	84ce                	mv	s1,s3
    800016aa:	b7c1                	j	8000166a <copyout+0x28>
  }
  return 0;
    800016ac:	4501                	li	a0,0
    800016ae:	a021                	j	800016b6 <copyout+0x74>
    800016b0:	4501                	li	a0,0
}
    800016b2:	8082                	ret
      return -1;
    800016b4:	557d                	li	a0,-1
}
    800016b6:	60a6                	ld	ra,72(sp)
    800016b8:	6406                	ld	s0,64(sp)
    800016ba:	74e2                	ld	s1,56(sp)
    800016bc:	7942                	ld	s2,48(sp)
    800016be:	79a2                	ld	s3,40(sp)
    800016c0:	7a02                	ld	s4,32(sp)
    800016c2:	6ae2                	ld	s5,24(sp)
    800016c4:	6b42                	ld	s6,16(sp)
    800016c6:	6ba2                	ld	s7,8(sp)
    800016c8:	6c02                	ld	s8,0(sp)
    800016ca:	6161                	addi	sp,sp,80
    800016cc:	8082                	ret

00000000800016ce <copyin>:
int
copyin(pagetable_t pagetable, char *dst, uint64 srcva, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    800016ce:	caa5                	beqz	a3,8000173e <copyin+0x70>
{
    800016d0:	715d                	addi	sp,sp,-80
    800016d2:	e486                	sd	ra,72(sp)
    800016d4:	e0a2                	sd	s0,64(sp)
    800016d6:	fc26                	sd	s1,56(sp)
    800016d8:	f84a                	sd	s2,48(sp)
    800016da:	f44e                	sd	s3,40(sp)
    800016dc:	f052                	sd	s4,32(sp)
    800016de:	ec56                	sd	s5,24(sp)
    800016e0:	e85a                	sd	s6,16(sp)
    800016e2:	e45e                	sd	s7,8(sp)
    800016e4:	e062                	sd	s8,0(sp)
    800016e6:	0880                	addi	s0,sp,80
    800016e8:	8b2a                	mv	s6,a0
    800016ea:	8a2e                	mv	s4,a1
    800016ec:	8c32                	mv	s8,a2
    800016ee:	89b6                	mv	s3,a3
    va0 = PGROUNDDOWN(srcva);
    800016f0:	7bfd                	lui	s7,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    800016f2:	6a85                	lui	s5,0x1
    800016f4:	a01d                	j	8000171a <copyin+0x4c>
    if(n > len)
      n = len;
    memmove(dst, (void *)(pa0 + (srcva - va0)), n);
    800016f6:	018505b3          	add	a1,a0,s8
    800016fa:	0004861b          	sext.w	a2,s1
    800016fe:	412585b3          	sub	a1,a1,s2
    80001702:	8552                	mv	a0,s4
    80001704:	fffff097          	auipc	ra,0xfffff
    80001708:	616080e7          	jalr	1558(ra) # 80000d1a <memmove>

    len -= n;
    8000170c:	409989b3          	sub	s3,s3,s1
    dst += n;
    80001710:	9a26                	add	s4,s4,s1
    srcva = va0 + PGSIZE;
    80001712:	01590c33          	add	s8,s2,s5
  while(len > 0){
    80001716:	02098263          	beqz	s3,8000173a <copyin+0x6c>
    va0 = PGROUNDDOWN(srcva);
    8000171a:	017c7933          	and	s2,s8,s7
    pa0 = walkaddr(pagetable, va0);
    8000171e:	85ca                	mv	a1,s2
    80001720:	855a                	mv	a0,s6
    80001722:	00000097          	auipc	ra,0x0
    80001726:	92a080e7          	jalr	-1750(ra) # 8000104c <walkaddr>
    if(pa0 == 0)
    8000172a:	cd01                	beqz	a0,80001742 <copyin+0x74>
    n = PGSIZE - (srcva - va0);
    8000172c:	418904b3          	sub	s1,s2,s8
    80001730:	94d6                	add	s1,s1,s5
    80001732:	fc99f2e3          	bgeu	s3,s1,800016f6 <copyin+0x28>
    80001736:	84ce                	mv	s1,s3
    80001738:	bf7d                	j	800016f6 <copyin+0x28>
  }
  return 0;
    8000173a:	4501                	li	a0,0
    8000173c:	a021                	j	80001744 <copyin+0x76>
    8000173e:	4501                	li	a0,0
}
    80001740:	8082                	ret
      return -1;
    80001742:	557d                	li	a0,-1
}
    80001744:	60a6                	ld	ra,72(sp)
    80001746:	6406                	ld	s0,64(sp)
    80001748:	74e2                	ld	s1,56(sp)
    8000174a:	7942                	ld	s2,48(sp)
    8000174c:	79a2                	ld	s3,40(sp)
    8000174e:	7a02                	ld	s4,32(sp)
    80001750:	6ae2                	ld	s5,24(sp)
    80001752:	6b42                	ld	s6,16(sp)
    80001754:	6ba2                	ld	s7,8(sp)
    80001756:	6c02                	ld	s8,0(sp)
    80001758:	6161                	addi	sp,sp,80
    8000175a:	8082                	ret

000000008000175c <copyinstr>:
copyinstr(pagetable_t pagetable, char *dst, uint64 srcva, uint64 max)
{
  uint64 n, va0, pa0;
  int got_null = 0;

  while(got_null == 0 && max > 0){
    8000175c:	c2dd                	beqz	a3,80001802 <copyinstr+0xa6>
{
    8000175e:	715d                	addi	sp,sp,-80
    80001760:	e486                	sd	ra,72(sp)
    80001762:	e0a2                	sd	s0,64(sp)
    80001764:	fc26                	sd	s1,56(sp)
    80001766:	f84a                	sd	s2,48(sp)
    80001768:	f44e                	sd	s3,40(sp)
    8000176a:	f052                	sd	s4,32(sp)
    8000176c:	ec56                	sd	s5,24(sp)
    8000176e:	e85a                	sd	s6,16(sp)
    80001770:	e45e                	sd	s7,8(sp)
    80001772:	0880                	addi	s0,sp,80
    80001774:	8a2a                	mv	s4,a0
    80001776:	8b2e                	mv	s6,a1
    80001778:	8bb2                	mv	s7,a2
    8000177a:	84b6                	mv	s1,a3
    va0 = PGROUNDDOWN(srcva);
    8000177c:	7afd                	lui	s5,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    8000177e:	6985                	lui	s3,0x1
    80001780:	a02d                	j	800017aa <copyinstr+0x4e>
      n = max;

    char *p = (char *) (pa0 + (srcva - va0));
    while(n > 0){
      if(*p == '\0'){
        *dst = '\0';
    80001782:	00078023          	sb	zero,0(a5) # 1000 <_entry-0x7ffff000>
    80001786:	4785                	li	a5,1
      dst++;
    }

    srcva = va0 + PGSIZE;
  }
  if(got_null){
    80001788:	37fd                	addiw	a5,a5,-1
    8000178a:	0007851b          	sext.w	a0,a5
    return 0;
  } else {
    return -1;
  }
}
    8000178e:	60a6                	ld	ra,72(sp)
    80001790:	6406                	ld	s0,64(sp)
    80001792:	74e2                	ld	s1,56(sp)
    80001794:	7942                	ld	s2,48(sp)
    80001796:	79a2                	ld	s3,40(sp)
    80001798:	7a02                	ld	s4,32(sp)
    8000179a:	6ae2                	ld	s5,24(sp)
    8000179c:	6b42                	ld	s6,16(sp)
    8000179e:	6ba2                	ld	s7,8(sp)
    800017a0:	6161                	addi	sp,sp,80
    800017a2:	8082                	ret
    srcva = va0 + PGSIZE;
    800017a4:	01390bb3          	add	s7,s2,s3
  while(got_null == 0 && max > 0){
    800017a8:	c8a9                	beqz	s1,800017fa <copyinstr+0x9e>
    va0 = PGROUNDDOWN(srcva);
    800017aa:	015bf933          	and	s2,s7,s5
    pa0 = walkaddr(pagetable, va0);
    800017ae:	85ca                	mv	a1,s2
    800017b0:	8552                	mv	a0,s4
    800017b2:	00000097          	auipc	ra,0x0
    800017b6:	89a080e7          	jalr	-1894(ra) # 8000104c <walkaddr>
    if(pa0 == 0)
    800017ba:	c131                	beqz	a0,800017fe <copyinstr+0xa2>
    n = PGSIZE - (srcva - va0);
    800017bc:	417906b3          	sub	a3,s2,s7
    800017c0:	96ce                	add	a3,a3,s3
    800017c2:	00d4f363          	bgeu	s1,a3,800017c8 <copyinstr+0x6c>
    800017c6:	86a6                	mv	a3,s1
    char *p = (char *) (pa0 + (srcva - va0));
    800017c8:	955e                	add	a0,a0,s7
    800017ca:	41250533          	sub	a0,a0,s2
    while(n > 0){
    800017ce:	daf9                	beqz	a3,800017a4 <copyinstr+0x48>
    800017d0:	87da                	mv	a5,s6
      if(*p == '\0'){
    800017d2:	41650633          	sub	a2,a0,s6
    800017d6:	fff48593          	addi	a1,s1,-1
    800017da:	95da                	add	a1,a1,s6
    while(n > 0){
    800017dc:	96da                	add	a3,a3,s6
      if(*p == '\0'){
    800017de:	00f60733          	add	a4,a2,a5
    800017e2:	00074703          	lbu	a4,0(a4) # fffffffffffff000 <end+0xffffffff7ffde000>
    800017e6:	df51                	beqz	a4,80001782 <copyinstr+0x26>
        *dst = *p;
    800017e8:	00e78023          	sb	a4,0(a5)
      --max;
    800017ec:	40f584b3          	sub	s1,a1,a5
      dst++;
    800017f0:	0785                	addi	a5,a5,1
    while(n > 0){
    800017f2:	fed796e3          	bne	a5,a3,800017de <copyinstr+0x82>
      dst++;
    800017f6:	8b3e                	mv	s6,a5
    800017f8:	b775                	j	800017a4 <copyinstr+0x48>
    800017fa:	4781                	li	a5,0
    800017fc:	b771                	j	80001788 <copyinstr+0x2c>
      return -1;
    800017fe:	557d                	li	a0,-1
    80001800:	b779                	j	8000178e <copyinstr+0x32>
  int got_null = 0;
    80001802:	4781                	li	a5,0
  if(got_null){
    80001804:	37fd                	addiw	a5,a5,-1
    80001806:	0007851b          	sext.w	a0,a5
}
    8000180a:	8082                	ret

000000008000180c <wakeup1>:

// Wake up p if it is sleeping in wait(); used by exit().
// Caller must hold p->lock.
static void
wakeup1(struct proc *p)
{
    8000180c:	1101                	addi	sp,sp,-32
    8000180e:	ec06                	sd	ra,24(sp)
    80001810:	e822                	sd	s0,16(sp)
    80001812:	e426                	sd	s1,8(sp)
    80001814:	1000                	addi	s0,sp,32
    80001816:	84aa                	mv	s1,a0
  if(!holding(&p->lock))
    80001818:	fffff097          	auipc	ra,0xfffff
    8000181c:	330080e7          	jalr	816(ra) # 80000b48 <holding>
    80001820:	c909                	beqz	a0,80001832 <wakeup1+0x26>
    panic("wakeup1");
  if(p->chan == p && p->state == SLEEPING) {
    80001822:	749c                	ld	a5,40(s1)
    80001824:	00978f63          	beq	a5,s1,80001842 <wakeup1+0x36>
    p->state = RUNNABLE;
  }
}
    80001828:	60e2                	ld	ra,24(sp)
    8000182a:	6442                	ld	s0,16(sp)
    8000182c:	64a2                	ld	s1,8(sp)
    8000182e:	6105                	addi	sp,sp,32
    80001830:	8082                	ret
    panic("wakeup1");
    80001832:	00007517          	auipc	a0,0x7
    80001836:	98e50513          	addi	a0,a0,-1650 # 800081c0 <digits+0x180>
    8000183a:	fffff097          	auipc	ra,0xfffff
    8000183e:	cf2080e7          	jalr	-782(ra) # 8000052c <panic>
  if(p->chan == p && p->state == SLEEPING) {
    80001842:	4c98                	lw	a4,24(s1)
    80001844:	4785                	li	a5,1
    80001846:	fef711e3          	bne	a4,a5,80001828 <wakeup1+0x1c>
    p->state = RUNNABLE;
    8000184a:	4789                	li	a5,2
    8000184c:	cc9c                	sw	a5,24(s1)
}
    8000184e:	bfe9                	j	80001828 <wakeup1+0x1c>

0000000080001850 <proc_mapstacks>:
proc_mapstacks(pagetable_t kpgtbl) {
    80001850:	7139                	addi	sp,sp,-64
    80001852:	fc06                	sd	ra,56(sp)
    80001854:	f822                	sd	s0,48(sp)
    80001856:	f426                	sd	s1,40(sp)
    80001858:	f04a                	sd	s2,32(sp)
    8000185a:	ec4e                	sd	s3,24(sp)
    8000185c:	e852                	sd	s4,16(sp)
    8000185e:	e456                	sd	s5,8(sp)
    80001860:	e05a                	sd	s6,0(sp)
    80001862:	0080                	addi	s0,sp,64
    80001864:	89aa                	mv	s3,a0
  for(p = proc; p < &proc[NPROC]; p++) {
    80001866:	00010497          	auipc	s1,0x10
    8000186a:	e5248493          	addi	s1,s1,-430 # 800116b8 <proc>
    uint64 va = KSTACK((int) (p - proc));
    8000186e:	8b26                	mv	s6,s1
    80001870:	00006a97          	auipc	s5,0x6
    80001874:	790a8a93          	addi	s5,s5,1936 # 80008000 <etext>
    80001878:	04000937          	lui	s2,0x4000
    8000187c:	197d                	addi	s2,s2,-1 # 3ffffff <_entry-0x7c000001>
    8000187e:	0932                	slli	s2,s2,0xc
  for(p = proc; p < &proc[NPROC]; p++) {
    80001880:	00011a17          	auipc	s4,0x11
    80001884:	c48a0a13          	addi	s4,s4,-952 # 800124c8 <tickslock>
    char *pa = kalloc();
    80001888:	fffff097          	auipc	ra,0xfffff
    8000188c:	24a080e7          	jalr	586(ra) # 80000ad2 <kalloc>
    80001890:	862a                	mv	a2,a0
    if(pa == 0)
    80001892:	c131                	beqz	a0,800018d6 <proc_mapstacks+0x86>
    uint64 va = KSTACK((int) (p - proc));
    80001894:	416485b3          	sub	a1,s1,s6
    80001898:	858d                	srai	a1,a1,0x3
    8000189a:	000ab783          	ld	a5,0(s5)
    8000189e:	02f585b3          	mul	a1,a1,a5
    800018a2:	2585                	addiw	a1,a1,1
    800018a4:	00d5959b          	slliw	a1,a1,0xd
    kvmmap(kpgtbl, va, (uint64)pa, PGSIZE, PTE_R | PTE_W);
    800018a8:	4719                	li	a4,6
    800018aa:	6685                	lui	a3,0x1
    800018ac:	40b905b3          	sub	a1,s2,a1
    800018b0:	854e                	mv	a0,s3
    800018b2:	00000097          	auipc	ra,0x0
    800018b6:	86a080e7          	jalr	-1942(ra) # 8000111c <kvmmap>
  for(p = proc; p < &proc[NPROC]; p++) {
    800018ba:	16848493          	addi	s1,s1,360
    800018be:	fd4495e3          	bne	s1,s4,80001888 <proc_mapstacks+0x38>
}
    800018c2:	70e2                	ld	ra,56(sp)
    800018c4:	7442                	ld	s0,48(sp)
    800018c6:	74a2                	ld	s1,40(sp)
    800018c8:	7902                	ld	s2,32(sp)
    800018ca:	69e2                	ld	s3,24(sp)
    800018cc:	6a42                	ld	s4,16(sp)
    800018ce:	6aa2                	ld	s5,8(sp)
    800018d0:	6b02                	ld	s6,0(sp)
    800018d2:	6121                	addi	sp,sp,64
    800018d4:	8082                	ret
      panic("kalloc");
    800018d6:	00007517          	auipc	a0,0x7
    800018da:	8f250513          	addi	a0,a0,-1806 # 800081c8 <digits+0x188>
    800018de:	fffff097          	auipc	ra,0xfffff
    800018e2:	c4e080e7          	jalr	-946(ra) # 8000052c <panic>

00000000800018e6 <procinit>:
{
    800018e6:	7139                	addi	sp,sp,-64
    800018e8:	fc06                	sd	ra,56(sp)
    800018ea:	f822                	sd	s0,48(sp)
    800018ec:	f426                	sd	s1,40(sp)
    800018ee:	f04a                	sd	s2,32(sp)
    800018f0:	ec4e                	sd	s3,24(sp)
    800018f2:	e852                	sd	s4,16(sp)
    800018f4:	e456                	sd	s5,8(sp)
    800018f6:	e05a                	sd	s6,0(sp)
    800018f8:	0080                	addi	s0,sp,64
  initlock(&pid_lock, "nextpid");
    800018fa:	00007597          	auipc	a1,0x7
    800018fe:	8d658593          	addi	a1,a1,-1834 # 800081d0 <digits+0x190>
    80001902:	00010517          	auipc	a0,0x10
    80001906:	99e50513          	addi	a0,a0,-1634 # 800112a0 <pid_lock>
    8000190a:	fffff097          	auipc	ra,0xfffff
    8000190e:	228080e7          	jalr	552(ra) # 80000b32 <initlock>
  for(p = proc; p < &proc[NPROC]; p++) {
    80001912:	00010497          	auipc	s1,0x10
    80001916:	da648493          	addi	s1,s1,-602 # 800116b8 <proc>
      initlock(&p->lock, "proc");
    8000191a:	00007b17          	auipc	s6,0x7
    8000191e:	8beb0b13          	addi	s6,s6,-1858 # 800081d8 <digits+0x198>
      p->kstack = KSTACK((int) (p - proc));
    80001922:	8aa6                	mv	s5,s1
    80001924:	00006a17          	auipc	s4,0x6
    80001928:	6dca0a13          	addi	s4,s4,1756 # 80008000 <etext>
    8000192c:	04000937          	lui	s2,0x4000
    80001930:	197d                	addi	s2,s2,-1 # 3ffffff <_entry-0x7c000001>
    80001932:	0932                	slli	s2,s2,0xc
  for(p = proc; p < &proc[NPROC]; p++) {
    80001934:	00011997          	auipc	s3,0x11
    80001938:	b9498993          	addi	s3,s3,-1132 # 800124c8 <tickslock>
      initlock(&p->lock, "proc");
    8000193c:	85da                	mv	a1,s6
    8000193e:	8526                	mv	a0,s1
    80001940:	fffff097          	auipc	ra,0xfffff
    80001944:	1f2080e7          	jalr	498(ra) # 80000b32 <initlock>
      p->kstack = KSTACK((int) (p - proc));
    80001948:	415487b3          	sub	a5,s1,s5
    8000194c:	878d                	srai	a5,a5,0x3
    8000194e:	000a3703          	ld	a4,0(s4)
    80001952:	02e787b3          	mul	a5,a5,a4
    80001956:	2785                	addiw	a5,a5,1
    80001958:	00d7979b          	slliw	a5,a5,0xd
    8000195c:	40f907b3          	sub	a5,s2,a5
    80001960:	e0bc                	sd	a5,64(s1)
  for(p = proc; p < &proc[NPROC]; p++) {
    80001962:	16848493          	addi	s1,s1,360
    80001966:	fd349be3          	bne	s1,s3,8000193c <procinit+0x56>
}
    8000196a:	70e2                	ld	ra,56(sp)
    8000196c:	7442                	ld	s0,48(sp)
    8000196e:	74a2                	ld	s1,40(sp)
    80001970:	7902                	ld	s2,32(sp)
    80001972:	69e2                	ld	s3,24(sp)
    80001974:	6a42                	ld	s4,16(sp)
    80001976:	6aa2                	ld	s5,8(sp)
    80001978:	6b02                	ld	s6,0(sp)
    8000197a:	6121                	addi	sp,sp,64
    8000197c:	8082                	ret

000000008000197e <cpuid>:
{
    8000197e:	1141                	addi	sp,sp,-16
    80001980:	e422                	sd	s0,8(sp)
    80001982:	0800                	addi	s0,sp,16
  asm volatile("mv %0, tp" : "=r" (x) );
    80001984:	8512                	mv	a0,tp
}
    80001986:	2501                	sext.w	a0,a0
    80001988:	6422                	ld	s0,8(sp)
    8000198a:	0141                	addi	sp,sp,16
    8000198c:	8082                	ret

000000008000198e <mycpu>:
mycpu(void) {
    8000198e:	1141                	addi	sp,sp,-16
    80001990:	e422                	sd	s0,8(sp)
    80001992:	0800                	addi	s0,sp,16
    80001994:	8792                	mv	a5,tp
  struct cpu *c = &cpus[id];
    80001996:	2781                	sext.w	a5,a5
    80001998:	079e                	slli	a5,a5,0x7
}
    8000199a:	00010517          	auipc	a0,0x10
    8000199e:	91e50513          	addi	a0,a0,-1762 # 800112b8 <cpus>
    800019a2:	953e                	add	a0,a0,a5
    800019a4:	6422                	ld	s0,8(sp)
    800019a6:	0141                	addi	sp,sp,16
    800019a8:	8082                	ret

00000000800019aa <myproc>:
myproc(void) {
    800019aa:	1101                	addi	sp,sp,-32
    800019ac:	ec06                	sd	ra,24(sp)
    800019ae:	e822                	sd	s0,16(sp)
    800019b0:	e426                	sd	s1,8(sp)
    800019b2:	1000                	addi	s0,sp,32
  push_off();
    800019b4:	fffff097          	auipc	ra,0xfffff
    800019b8:	1c2080e7          	jalr	450(ra) # 80000b76 <push_off>
    800019bc:	8792                	mv	a5,tp
  struct proc *p = c->proc;
    800019be:	2781                	sext.w	a5,a5
    800019c0:	079e                	slli	a5,a5,0x7
    800019c2:	00010717          	auipc	a4,0x10
    800019c6:	8de70713          	addi	a4,a4,-1826 # 800112a0 <pid_lock>
    800019ca:	97ba                	add	a5,a5,a4
    800019cc:	6f84                	ld	s1,24(a5)
  pop_off();
    800019ce:	fffff097          	auipc	ra,0xfffff
    800019d2:	248080e7          	jalr	584(ra) # 80000c16 <pop_off>
}
    800019d6:	8526                	mv	a0,s1
    800019d8:	60e2                	ld	ra,24(sp)
    800019da:	6442                	ld	s0,16(sp)
    800019dc:	64a2                	ld	s1,8(sp)
    800019de:	6105                	addi	sp,sp,32
    800019e0:	8082                	ret

00000000800019e2 <forkret>:
{
    800019e2:	1141                	addi	sp,sp,-16
    800019e4:	e406                	sd	ra,8(sp)
    800019e6:	e022                	sd	s0,0(sp)
    800019e8:	0800                	addi	s0,sp,16
  release(&myproc()->lock);
    800019ea:	00000097          	auipc	ra,0x0
    800019ee:	fc0080e7          	jalr	-64(ra) # 800019aa <myproc>
    800019f2:	fffff097          	auipc	ra,0xfffff
    800019f6:	284080e7          	jalr	644(ra) # 80000c76 <release>
  if (first) {
    800019fa:	00007797          	auipc	a5,0x7
    800019fe:	df67a783          	lw	a5,-522(a5) # 800087f0 <first.1>
    80001a02:	eb89                	bnez	a5,80001a14 <forkret+0x32>
  usertrapret();
    80001a04:	00001097          	auipc	ra,0x1
    80001a08:	c1e080e7          	jalr	-994(ra) # 80002622 <usertrapret>
}
    80001a0c:	60a2                	ld	ra,8(sp)
    80001a0e:	6402                	ld	s0,0(sp)
    80001a10:	0141                	addi	sp,sp,16
    80001a12:	8082                	ret
    first = 0;
    80001a14:	00007797          	auipc	a5,0x7
    80001a18:	dc07ae23          	sw	zero,-548(a5) # 800087f0 <first.1>
    fsinit(ROOTDEV);
    80001a1c:	4505                	li	a0,1
    80001a1e:	00002097          	auipc	ra,0x2
    80001a22:	a0c080e7          	jalr	-1524(ra) # 8000342a <fsinit>
    80001a26:	bff9                	j	80001a04 <forkret+0x22>

0000000080001a28 <allocpid>:
allocpid() {
    80001a28:	1101                	addi	sp,sp,-32
    80001a2a:	ec06                	sd	ra,24(sp)
    80001a2c:	e822                	sd	s0,16(sp)
    80001a2e:	e426                	sd	s1,8(sp)
    80001a30:	e04a                	sd	s2,0(sp)
    80001a32:	1000                	addi	s0,sp,32
  acquire(&pid_lock);
    80001a34:	00010917          	auipc	s2,0x10
    80001a38:	86c90913          	addi	s2,s2,-1940 # 800112a0 <pid_lock>
    80001a3c:	854a                	mv	a0,s2
    80001a3e:	fffff097          	auipc	ra,0xfffff
    80001a42:	184080e7          	jalr	388(ra) # 80000bc2 <acquire>
  pid = nextpid;
    80001a46:	00007797          	auipc	a5,0x7
    80001a4a:	dae78793          	addi	a5,a5,-594 # 800087f4 <nextpid>
    80001a4e:	4384                	lw	s1,0(a5)
  nextpid = nextpid + 1;
    80001a50:	0014871b          	addiw	a4,s1,1
    80001a54:	c398                	sw	a4,0(a5)
  release(&pid_lock);
    80001a56:	854a                	mv	a0,s2
    80001a58:	fffff097          	auipc	ra,0xfffff
    80001a5c:	21e080e7          	jalr	542(ra) # 80000c76 <release>
}
    80001a60:	8526                	mv	a0,s1
    80001a62:	60e2                	ld	ra,24(sp)
    80001a64:	6442                	ld	s0,16(sp)
    80001a66:	64a2                	ld	s1,8(sp)
    80001a68:	6902                	ld	s2,0(sp)
    80001a6a:	6105                	addi	sp,sp,32
    80001a6c:	8082                	ret

0000000080001a6e <proc_pagetable>:
{
    80001a6e:	1101                	addi	sp,sp,-32
    80001a70:	ec06                	sd	ra,24(sp)
    80001a72:	e822                	sd	s0,16(sp)
    80001a74:	e426                	sd	s1,8(sp)
    80001a76:	e04a                	sd	s2,0(sp)
    80001a78:	1000                	addi	s0,sp,32
    80001a7a:	892a                	mv	s2,a0
  pagetable = uvmcreate();
    80001a7c:	00000097          	auipc	ra,0x0
    80001a80:	88a080e7          	jalr	-1910(ra) # 80001306 <uvmcreate>
    80001a84:	84aa                	mv	s1,a0
  if(pagetable == 0)
    80001a86:	c121                	beqz	a0,80001ac6 <proc_pagetable+0x58>
  if(mappages(pagetable, TRAMPOLINE, PGSIZE,
    80001a88:	4729                	li	a4,10
    80001a8a:	00005697          	auipc	a3,0x5
    80001a8e:	57668693          	addi	a3,a3,1398 # 80007000 <_trampoline>
    80001a92:	6605                	lui	a2,0x1
    80001a94:	040005b7          	lui	a1,0x4000
    80001a98:	15fd                	addi	a1,a1,-1 # 3ffffff <_entry-0x7c000001>
    80001a9a:	05b2                	slli	a1,a1,0xc
    80001a9c:	fffff097          	auipc	ra,0xfffff
    80001aa0:	5f2080e7          	jalr	1522(ra) # 8000108e <mappages>
    80001aa4:	02054863          	bltz	a0,80001ad4 <proc_pagetable+0x66>
  if(mappages(pagetable, TRAPFRAME, PGSIZE,
    80001aa8:	4719                	li	a4,6
    80001aaa:	05893683          	ld	a3,88(s2)
    80001aae:	6605                	lui	a2,0x1
    80001ab0:	020005b7          	lui	a1,0x2000
    80001ab4:	15fd                	addi	a1,a1,-1 # 1ffffff <_entry-0x7e000001>
    80001ab6:	05b6                	slli	a1,a1,0xd
    80001ab8:	8526                	mv	a0,s1
    80001aba:	fffff097          	auipc	ra,0xfffff
    80001abe:	5d4080e7          	jalr	1492(ra) # 8000108e <mappages>
    80001ac2:	02054163          	bltz	a0,80001ae4 <proc_pagetable+0x76>
}
    80001ac6:	8526                	mv	a0,s1
    80001ac8:	60e2                	ld	ra,24(sp)
    80001aca:	6442                	ld	s0,16(sp)
    80001acc:	64a2                	ld	s1,8(sp)
    80001ace:	6902                	ld	s2,0(sp)
    80001ad0:	6105                	addi	sp,sp,32
    80001ad2:	8082                	ret
    uvmfree(pagetable, 0);
    80001ad4:	4581                	li	a1,0
    80001ad6:	8526                	mv	a0,s1
    80001ad8:	00000097          	auipc	ra,0x0
    80001adc:	a2c080e7          	jalr	-1492(ra) # 80001504 <uvmfree>
    return 0;
    80001ae0:	4481                	li	s1,0
    80001ae2:	b7d5                	j	80001ac6 <proc_pagetable+0x58>
    uvmunmap(pagetable, TRAMPOLINE, 1, 0);
    80001ae4:	4681                	li	a3,0
    80001ae6:	4605                	li	a2,1
    80001ae8:	040005b7          	lui	a1,0x4000
    80001aec:	15fd                	addi	a1,a1,-1 # 3ffffff <_entry-0x7c000001>
    80001aee:	05b2                	slli	a1,a1,0xc
    80001af0:	8526                	mv	a0,s1
    80001af2:	fffff097          	auipc	ra,0xfffff
    80001af6:	750080e7          	jalr	1872(ra) # 80001242 <uvmunmap>
    uvmfree(pagetable, 0);
    80001afa:	4581                	li	a1,0
    80001afc:	8526                	mv	a0,s1
    80001afe:	00000097          	auipc	ra,0x0
    80001b02:	a06080e7          	jalr	-1530(ra) # 80001504 <uvmfree>
    return 0;
    80001b06:	4481                	li	s1,0
    80001b08:	bf7d                	j	80001ac6 <proc_pagetable+0x58>

0000000080001b0a <proc_freepagetable>:
{
    80001b0a:	1101                	addi	sp,sp,-32
    80001b0c:	ec06                	sd	ra,24(sp)
    80001b0e:	e822                	sd	s0,16(sp)
    80001b10:	e426                	sd	s1,8(sp)
    80001b12:	e04a                	sd	s2,0(sp)
    80001b14:	1000                	addi	s0,sp,32
    80001b16:	84aa                	mv	s1,a0
    80001b18:	892e                	mv	s2,a1
  uvmunmap(pagetable, TRAMPOLINE, 1, 0);
    80001b1a:	4681                	li	a3,0
    80001b1c:	4605                	li	a2,1
    80001b1e:	040005b7          	lui	a1,0x4000
    80001b22:	15fd                	addi	a1,a1,-1 # 3ffffff <_entry-0x7c000001>
    80001b24:	05b2                	slli	a1,a1,0xc
    80001b26:	fffff097          	auipc	ra,0xfffff
    80001b2a:	71c080e7          	jalr	1820(ra) # 80001242 <uvmunmap>
  uvmunmap(pagetable, TRAPFRAME, 1, 0);
    80001b2e:	4681                	li	a3,0
    80001b30:	4605                	li	a2,1
    80001b32:	020005b7          	lui	a1,0x2000
    80001b36:	15fd                	addi	a1,a1,-1 # 1ffffff <_entry-0x7e000001>
    80001b38:	05b6                	slli	a1,a1,0xd
    80001b3a:	8526                	mv	a0,s1
    80001b3c:	fffff097          	auipc	ra,0xfffff
    80001b40:	706080e7          	jalr	1798(ra) # 80001242 <uvmunmap>
  uvmfree(pagetable, sz);
    80001b44:	85ca                	mv	a1,s2
    80001b46:	8526                	mv	a0,s1
    80001b48:	00000097          	auipc	ra,0x0
    80001b4c:	9bc080e7          	jalr	-1604(ra) # 80001504 <uvmfree>
}
    80001b50:	60e2                	ld	ra,24(sp)
    80001b52:	6442                	ld	s0,16(sp)
    80001b54:	64a2                	ld	s1,8(sp)
    80001b56:	6902                	ld	s2,0(sp)
    80001b58:	6105                	addi	sp,sp,32
    80001b5a:	8082                	ret

0000000080001b5c <freeproc>:
{
    80001b5c:	1101                	addi	sp,sp,-32
    80001b5e:	ec06                	sd	ra,24(sp)
    80001b60:	e822                	sd	s0,16(sp)
    80001b62:	e426                	sd	s1,8(sp)
    80001b64:	1000                	addi	s0,sp,32
    80001b66:	84aa                	mv	s1,a0
  if(p->trapframe)
    80001b68:	6d28                	ld	a0,88(a0)
    80001b6a:	c509                	beqz	a0,80001b74 <freeproc+0x18>
    kfree((void*)p->trapframe);
    80001b6c:	fffff097          	auipc	ra,0xfffff
    80001b70:	e68080e7          	jalr	-408(ra) # 800009d4 <kfree>
  p->trapframe = 0;
    80001b74:	0404bc23          	sd	zero,88(s1)
  if(p->pagetable)
    80001b78:	68a8                	ld	a0,80(s1)
    80001b7a:	c511                	beqz	a0,80001b86 <freeproc+0x2a>
    proc_freepagetable(p->pagetable, p->sz);
    80001b7c:	64ac                	ld	a1,72(s1)
    80001b7e:	00000097          	auipc	ra,0x0
    80001b82:	f8c080e7          	jalr	-116(ra) # 80001b0a <proc_freepagetable>
  p->pagetable = 0;
    80001b86:	0404b823          	sd	zero,80(s1)
  p->sz = 0;
    80001b8a:	0404b423          	sd	zero,72(s1)
  p->pid = 0;
    80001b8e:	0204ac23          	sw	zero,56(s1)
  p->parent = 0;
    80001b92:	0204b023          	sd	zero,32(s1)
  p->name[0] = 0;
    80001b96:	14048c23          	sb	zero,344(s1)
  p->chan = 0;
    80001b9a:	0204b423          	sd	zero,40(s1)
  p->killed = 0;
    80001b9e:	0204a823          	sw	zero,48(s1)
  p->xstate = 0;
    80001ba2:	0204aa23          	sw	zero,52(s1)
  p->state = UNUSED;
    80001ba6:	0004ac23          	sw	zero,24(s1)
}
    80001baa:	60e2                	ld	ra,24(sp)
    80001bac:	6442                	ld	s0,16(sp)
    80001bae:	64a2                	ld	s1,8(sp)
    80001bb0:	6105                	addi	sp,sp,32
    80001bb2:	8082                	ret

0000000080001bb4 <allocproc>:
{
    80001bb4:	1101                	addi	sp,sp,-32
    80001bb6:	ec06                	sd	ra,24(sp)
    80001bb8:	e822                	sd	s0,16(sp)
    80001bba:	e426                	sd	s1,8(sp)
    80001bbc:	e04a                	sd	s2,0(sp)
    80001bbe:	1000                	addi	s0,sp,32
  for(p = proc; p < &proc[NPROC]; p++) {
    80001bc0:	00010497          	auipc	s1,0x10
    80001bc4:	af848493          	addi	s1,s1,-1288 # 800116b8 <proc>
    80001bc8:	00011917          	auipc	s2,0x11
    80001bcc:	90090913          	addi	s2,s2,-1792 # 800124c8 <tickslock>
    acquire(&p->lock);
    80001bd0:	8526                	mv	a0,s1
    80001bd2:	fffff097          	auipc	ra,0xfffff
    80001bd6:	ff0080e7          	jalr	-16(ra) # 80000bc2 <acquire>
    if(p->state == UNUSED) {
    80001bda:	4c9c                	lw	a5,24(s1)
    80001bdc:	c395                	beqz	a5,80001c00 <allocproc+0x4c>
      release(&p->lock);
    80001bde:	8526                	mv	a0,s1
    80001be0:	fffff097          	auipc	ra,0xfffff
    80001be4:	096080e7          	jalr	150(ra) # 80000c76 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    80001be8:	16848493          	addi	s1,s1,360
    80001bec:	ff2492e3          	bne	s1,s2,80001bd0 <allocproc+0x1c>
  return 0;
    80001bf0:	4481                	li	s1,0
}
    80001bf2:	8526                	mv	a0,s1
    80001bf4:	60e2                	ld	ra,24(sp)
    80001bf6:	6442                	ld	s0,16(sp)
    80001bf8:	64a2                	ld	s1,8(sp)
    80001bfa:	6902                	ld	s2,0(sp)
    80001bfc:	6105                	addi	sp,sp,32
    80001bfe:	8082                	ret
  p->pid = allocpid();
    80001c00:	00000097          	auipc	ra,0x0
    80001c04:	e28080e7          	jalr	-472(ra) # 80001a28 <allocpid>
    80001c08:	dc88                	sw	a0,56(s1)
  if((p->trapframe = (struct trapframe *)kalloc()) == 0){
    80001c0a:	fffff097          	auipc	ra,0xfffff
    80001c0e:	ec8080e7          	jalr	-312(ra) # 80000ad2 <kalloc>
    80001c12:	892a                	mv	s2,a0
    80001c14:	eca8                	sd	a0,88(s1)
    80001c16:	cd05                	beqz	a0,80001c4e <allocproc+0x9a>
  p->pagetable = proc_pagetable(p);
    80001c18:	8526                	mv	a0,s1
    80001c1a:	00000097          	auipc	ra,0x0
    80001c1e:	e54080e7          	jalr	-428(ra) # 80001a6e <proc_pagetable>
    80001c22:	892a                	mv	s2,a0
    80001c24:	e8a8                	sd	a0,80(s1)
  if(p->pagetable == 0){
    80001c26:	c91d                	beqz	a0,80001c5c <allocproc+0xa8>
  memset(&p->context, 0, sizeof(p->context));
    80001c28:	07000613          	li	a2,112
    80001c2c:	4581                	li	a1,0
    80001c2e:	06048513          	addi	a0,s1,96
    80001c32:	fffff097          	auipc	ra,0xfffff
    80001c36:	08c080e7          	jalr	140(ra) # 80000cbe <memset>
  p->context.ra = (uint64)forkret;
    80001c3a:	00000797          	auipc	a5,0x0
    80001c3e:	da878793          	addi	a5,a5,-600 # 800019e2 <forkret>
    80001c42:	f0bc                	sd	a5,96(s1)
  p->context.sp = p->kstack + PGSIZE;
    80001c44:	60bc                	ld	a5,64(s1)
    80001c46:	6705                	lui	a4,0x1
    80001c48:	97ba                	add	a5,a5,a4
    80001c4a:	f4bc                	sd	a5,104(s1)
  return p;
    80001c4c:	b75d                	j	80001bf2 <allocproc+0x3e>
    release(&p->lock);
    80001c4e:	8526                	mv	a0,s1
    80001c50:	fffff097          	auipc	ra,0xfffff
    80001c54:	026080e7          	jalr	38(ra) # 80000c76 <release>
    return 0;
    80001c58:	84ca                	mv	s1,s2
    80001c5a:	bf61                	j	80001bf2 <allocproc+0x3e>
    freeproc(p);
    80001c5c:	8526                	mv	a0,s1
    80001c5e:	00000097          	auipc	ra,0x0
    80001c62:	efe080e7          	jalr	-258(ra) # 80001b5c <freeproc>
    release(&p->lock);
    80001c66:	8526                	mv	a0,s1
    80001c68:	fffff097          	auipc	ra,0xfffff
    80001c6c:	00e080e7          	jalr	14(ra) # 80000c76 <release>
    return 0;
    80001c70:	84ca                	mv	s1,s2
    80001c72:	b741                	j	80001bf2 <allocproc+0x3e>

0000000080001c74 <userinit>:
{
    80001c74:	1101                	addi	sp,sp,-32
    80001c76:	ec06                	sd	ra,24(sp)
    80001c78:	e822                	sd	s0,16(sp)
    80001c7a:	e426                	sd	s1,8(sp)
    80001c7c:	1000                	addi	s0,sp,32
  p = allocproc();
    80001c7e:	00000097          	auipc	ra,0x0
    80001c82:	f36080e7          	jalr	-202(ra) # 80001bb4 <allocproc>
    80001c86:	84aa                	mv	s1,a0
  initproc = p;
    80001c88:	00007797          	auipc	a5,0x7
    80001c8c:	3aa7b023          	sd	a0,928(a5) # 80009028 <initproc>
  uvminit(p->pagetable, initcode, sizeof(initcode));
    80001c90:	03400613          	li	a2,52
    80001c94:	00007597          	auipc	a1,0x7
    80001c98:	b6c58593          	addi	a1,a1,-1172 # 80008800 <initcode>
    80001c9c:	6928                	ld	a0,80(a0)
    80001c9e:	fffff097          	auipc	ra,0xfffff
    80001ca2:	696080e7          	jalr	1686(ra) # 80001334 <uvminit>
  p->sz = PGSIZE;
    80001ca6:	6785                	lui	a5,0x1
    80001ca8:	e4bc                	sd	a5,72(s1)
  p->trapframe->epc = 0;      // user program counter
    80001caa:	6cb8                	ld	a4,88(s1)
    80001cac:	00073c23          	sd	zero,24(a4) # 1018 <_entry-0x7fffefe8>
  p->trapframe->sp = PGSIZE;  // user stack pointer
    80001cb0:	6cb8                	ld	a4,88(s1)
    80001cb2:	fb1c                	sd	a5,48(a4)
  safestrcpy(p->name, "initcode", sizeof(p->name));
    80001cb4:	4641                	li	a2,16
    80001cb6:	00006597          	auipc	a1,0x6
    80001cba:	52a58593          	addi	a1,a1,1322 # 800081e0 <digits+0x1a0>
    80001cbe:	15848513          	addi	a0,s1,344
    80001cc2:	fffff097          	auipc	ra,0xfffff
    80001cc6:	14e080e7          	jalr	334(ra) # 80000e10 <safestrcpy>
  p->cwd = namei("/");
    80001cca:	00006517          	auipc	a0,0x6
    80001cce:	52650513          	addi	a0,a0,1318 # 800081f0 <digits+0x1b0>
    80001cd2:	00002097          	auipc	ra,0x2
    80001cd6:	29c080e7          	jalr	668(ra) # 80003f6e <namei>
    80001cda:	14a4b823          	sd	a0,336(s1)
  p->state = RUNNABLE;
    80001cde:	4789                	li	a5,2
    80001ce0:	cc9c                	sw	a5,24(s1)
  release(&p->lock);
    80001ce2:	8526                	mv	a0,s1
    80001ce4:	fffff097          	auipc	ra,0xfffff
    80001ce8:	f92080e7          	jalr	-110(ra) # 80000c76 <release>
}
    80001cec:	60e2                	ld	ra,24(sp)
    80001cee:	6442                	ld	s0,16(sp)
    80001cf0:	64a2                	ld	s1,8(sp)
    80001cf2:	6105                	addi	sp,sp,32
    80001cf4:	8082                	ret

0000000080001cf6 <growproc>:
{
    80001cf6:	1101                	addi	sp,sp,-32
    80001cf8:	ec06                	sd	ra,24(sp)
    80001cfa:	e822                	sd	s0,16(sp)
    80001cfc:	e426                	sd	s1,8(sp)
    80001cfe:	e04a                	sd	s2,0(sp)
    80001d00:	1000                	addi	s0,sp,32
    80001d02:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80001d04:	00000097          	auipc	ra,0x0
    80001d08:	ca6080e7          	jalr	-858(ra) # 800019aa <myproc>
    80001d0c:	892a                	mv	s2,a0
  sz = p->sz;
    80001d0e:	652c                	ld	a1,72(a0)
    80001d10:	0005879b          	sext.w	a5,a1
  if(n > 0){
    80001d14:	00904f63          	bgtz	s1,80001d32 <growproc+0x3c>
  } else if(n < 0){
    80001d18:	0204cd63          	bltz	s1,80001d52 <growproc+0x5c>
  p->sz = sz;
    80001d1c:	1782                	slli	a5,a5,0x20
    80001d1e:	9381                	srli	a5,a5,0x20
    80001d20:	04f93423          	sd	a5,72(s2)
  return 0;
    80001d24:	4501                	li	a0,0
}
    80001d26:	60e2                	ld	ra,24(sp)
    80001d28:	6442                	ld	s0,16(sp)
    80001d2a:	64a2                	ld	s1,8(sp)
    80001d2c:	6902                	ld	s2,0(sp)
    80001d2e:	6105                	addi	sp,sp,32
    80001d30:	8082                	ret
    if((sz = uvmalloc(p->pagetable, sz, sz + n)) == 0) {
    80001d32:	00f4863b          	addw	a2,s1,a5
    80001d36:	1602                	slli	a2,a2,0x20
    80001d38:	9201                	srli	a2,a2,0x20
    80001d3a:	1582                	slli	a1,a1,0x20
    80001d3c:	9181                	srli	a1,a1,0x20
    80001d3e:	6928                	ld	a0,80(a0)
    80001d40:	fffff097          	auipc	ra,0xfffff
    80001d44:	6ae080e7          	jalr	1710(ra) # 800013ee <uvmalloc>
    80001d48:	0005079b          	sext.w	a5,a0
    80001d4c:	fbe1                	bnez	a5,80001d1c <growproc+0x26>
      return -1;
    80001d4e:	557d                	li	a0,-1
    80001d50:	bfd9                	j	80001d26 <growproc+0x30>
    sz = uvmdealloc(p->pagetable, sz, sz + n);
    80001d52:	00f4863b          	addw	a2,s1,a5
    80001d56:	1602                	slli	a2,a2,0x20
    80001d58:	9201                	srli	a2,a2,0x20
    80001d5a:	1582                	slli	a1,a1,0x20
    80001d5c:	9181                	srli	a1,a1,0x20
    80001d5e:	6928                	ld	a0,80(a0)
    80001d60:	fffff097          	auipc	ra,0xfffff
    80001d64:	646080e7          	jalr	1606(ra) # 800013a6 <uvmdealloc>
    80001d68:	0005079b          	sext.w	a5,a0
    80001d6c:	bf45                	j	80001d1c <growproc+0x26>

0000000080001d6e <fork>:
{
    80001d6e:	7139                	addi	sp,sp,-64
    80001d70:	fc06                	sd	ra,56(sp)
    80001d72:	f822                	sd	s0,48(sp)
    80001d74:	f426                	sd	s1,40(sp)
    80001d76:	f04a                	sd	s2,32(sp)
    80001d78:	ec4e                	sd	s3,24(sp)
    80001d7a:	e852                	sd	s4,16(sp)
    80001d7c:	e456                	sd	s5,8(sp)
    80001d7e:	0080                	addi	s0,sp,64
  struct proc *p = myproc();
    80001d80:	00000097          	auipc	ra,0x0
    80001d84:	c2a080e7          	jalr	-982(ra) # 800019aa <myproc>
    80001d88:	8aaa                	mv	s5,a0
  if((np = allocproc()) == 0){
    80001d8a:	00000097          	auipc	ra,0x0
    80001d8e:	e2a080e7          	jalr	-470(ra) # 80001bb4 <allocproc>
    80001d92:	c17d                	beqz	a0,80001e78 <fork+0x10a>
    80001d94:	8a2a                	mv	s4,a0
  if(uvmcopy(p->pagetable, np->pagetable, p->sz) < 0){
    80001d96:	048ab603          	ld	a2,72(s5)
    80001d9a:	692c                	ld	a1,80(a0)
    80001d9c:	050ab503          	ld	a0,80(s5)
    80001da0:	fffff097          	auipc	ra,0xfffff
    80001da4:	79e080e7          	jalr	1950(ra) # 8000153e <uvmcopy>
    80001da8:	04054a63          	bltz	a0,80001dfc <fork+0x8e>
  np->sz = p->sz;
    80001dac:	048ab783          	ld	a5,72(s5)
    80001db0:	04fa3423          	sd	a5,72(s4)
  np->parent = p;
    80001db4:	035a3023          	sd	s5,32(s4)
  *(np->trapframe) = *(p->trapframe);
    80001db8:	058ab683          	ld	a3,88(s5)
    80001dbc:	87b6                	mv	a5,a3
    80001dbe:	058a3703          	ld	a4,88(s4)
    80001dc2:	12068693          	addi	a3,a3,288
    80001dc6:	0007b803          	ld	a6,0(a5) # 1000 <_entry-0x7ffff000>
    80001dca:	6788                	ld	a0,8(a5)
    80001dcc:	6b8c                	ld	a1,16(a5)
    80001dce:	6f90                	ld	a2,24(a5)
    80001dd0:	01073023          	sd	a6,0(a4)
    80001dd4:	e708                	sd	a0,8(a4)
    80001dd6:	eb0c                	sd	a1,16(a4)
    80001dd8:	ef10                	sd	a2,24(a4)
    80001dda:	02078793          	addi	a5,a5,32
    80001dde:	02070713          	addi	a4,a4,32
    80001de2:	fed792e3          	bne	a5,a3,80001dc6 <fork+0x58>
  np->trapframe->a0 = 0;
    80001de6:	058a3783          	ld	a5,88(s4)
    80001dea:	0607b823          	sd	zero,112(a5)
  for(i = 0; i < NOFILE; i++)
    80001dee:	0d0a8493          	addi	s1,s5,208
    80001df2:	0d0a0913          	addi	s2,s4,208
    80001df6:	150a8993          	addi	s3,s5,336
    80001dfa:	a00d                	j	80001e1c <fork+0xae>
    freeproc(np);
    80001dfc:	8552                	mv	a0,s4
    80001dfe:	00000097          	auipc	ra,0x0
    80001e02:	d5e080e7          	jalr	-674(ra) # 80001b5c <freeproc>
    release(&np->lock);
    80001e06:	8552                	mv	a0,s4
    80001e08:	fffff097          	auipc	ra,0xfffff
    80001e0c:	e6e080e7          	jalr	-402(ra) # 80000c76 <release>
    return -1;
    80001e10:	54fd                	li	s1,-1
    80001e12:	a889                	j	80001e64 <fork+0xf6>
  for(i = 0; i < NOFILE; i++)
    80001e14:	04a1                	addi	s1,s1,8
    80001e16:	0921                	addi	s2,s2,8
    80001e18:	01348b63          	beq	s1,s3,80001e2e <fork+0xc0>
    if(p->ofile[i])
    80001e1c:	6088                	ld	a0,0(s1)
    80001e1e:	d97d                	beqz	a0,80001e14 <fork+0xa6>
      np->ofile[i] = filedup(p->ofile[i]);
    80001e20:	00002097          	auipc	ra,0x2
    80001e24:	7ec080e7          	jalr	2028(ra) # 8000460c <filedup>
    80001e28:	00a93023          	sd	a0,0(s2)
    80001e2c:	b7e5                	j	80001e14 <fork+0xa6>
  np->cwd = idup(p->cwd);
    80001e2e:	150ab503          	ld	a0,336(s5)
    80001e32:	00002097          	auipc	ra,0x2
    80001e36:	834080e7          	jalr	-1996(ra) # 80003666 <idup>
    80001e3a:	14aa3823          	sd	a0,336(s4)
  safestrcpy(np->name, p->name, sizeof(p->name));
    80001e3e:	4641                	li	a2,16
    80001e40:	158a8593          	addi	a1,s5,344
    80001e44:	158a0513          	addi	a0,s4,344
    80001e48:	fffff097          	auipc	ra,0xfffff
    80001e4c:	fc8080e7          	jalr	-56(ra) # 80000e10 <safestrcpy>
  pid = np->pid;
    80001e50:	038a2483          	lw	s1,56(s4)
  np->state = RUNNABLE;
    80001e54:	4789                	li	a5,2
    80001e56:	00fa2c23          	sw	a5,24(s4)
  release(&np->lock);
    80001e5a:	8552                	mv	a0,s4
    80001e5c:	fffff097          	auipc	ra,0xfffff
    80001e60:	e1a080e7          	jalr	-486(ra) # 80000c76 <release>
}
    80001e64:	8526                	mv	a0,s1
    80001e66:	70e2                	ld	ra,56(sp)
    80001e68:	7442                	ld	s0,48(sp)
    80001e6a:	74a2                	ld	s1,40(sp)
    80001e6c:	7902                	ld	s2,32(sp)
    80001e6e:	69e2                	ld	s3,24(sp)
    80001e70:	6a42                	ld	s4,16(sp)
    80001e72:	6aa2                	ld	s5,8(sp)
    80001e74:	6121                	addi	sp,sp,64
    80001e76:	8082                	ret
    return -1;
    80001e78:	54fd                	li	s1,-1
    80001e7a:	b7ed                	j	80001e64 <fork+0xf6>

0000000080001e7c <reparent>:
{
    80001e7c:	7179                	addi	sp,sp,-48
    80001e7e:	f406                	sd	ra,40(sp)
    80001e80:	f022                	sd	s0,32(sp)
    80001e82:	ec26                	sd	s1,24(sp)
    80001e84:	e84a                	sd	s2,16(sp)
    80001e86:	e44e                	sd	s3,8(sp)
    80001e88:	e052                	sd	s4,0(sp)
    80001e8a:	1800                	addi	s0,sp,48
    80001e8c:	892a                	mv	s2,a0
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80001e8e:	00010497          	auipc	s1,0x10
    80001e92:	82a48493          	addi	s1,s1,-2006 # 800116b8 <proc>
      pp->parent = initproc;
    80001e96:	00007a17          	auipc	s4,0x7
    80001e9a:	192a0a13          	addi	s4,s4,402 # 80009028 <initproc>
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80001e9e:	00010997          	auipc	s3,0x10
    80001ea2:	62a98993          	addi	s3,s3,1578 # 800124c8 <tickslock>
    80001ea6:	a029                	j	80001eb0 <reparent+0x34>
    80001ea8:	16848493          	addi	s1,s1,360
    80001eac:	03348363          	beq	s1,s3,80001ed2 <reparent+0x56>
    if(pp->parent == p){
    80001eb0:	709c                	ld	a5,32(s1)
    80001eb2:	ff279be3          	bne	a5,s2,80001ea8 <reparent+0x2c>
      acquire(&pp->lock);
    80001eb6:	8526                	mv	a0,s1
    80001eb8:	fffff097          	auipc	ra,0xfffff
    80001ebc:	d0a080e7          	jalr	-758(ra) # 80000bc2 <acquire>
      pp->parent = initproc;
    80001ec0:	000a3783          	ld	a5,0(s4)
    80001ec4:	f09c                	sd	a5,32(s1)
      release(&pp->lock);
    80001ec6:	8526                	mv	a0,s1
    80001ec8:	fffff097          	auipc	ra,0xfffff
    80001ecc:	dae080e7          	jalr	-594(ra) # 80000c76 <release>
    80001ed0:	bfe1                	j	80001ea8 <reparent+0x2c>
}
    80001ed2:	70a2                	ld	ra,40(sp)
    80001ed4:	7402                	ld	s0,32(sp)
    80001ed6:	64e2                	ld	s1,24(sp)
    80001ed8:	6942                	ld	s2,16(sp)
    80001eda:	69a2                	ld	s3,8(sp)
    80001edc:	6a02                	ld	s4,0(sp)
    80001ede:	6145                	addi	sp,sp,48
    80001ee0:	8082                	ret

0000000080001ee2 <scheduler>:
{
    80001ee2:	711d                	addi	sp,sp,-96
    80001ee4:	ec86                	sd	ra,88(sp)
    80001ee6:	e8a2                	sd	s0,80(sp)
    80001ee8:	e4a6                	sd	s1,72(sp)
    80001eea:	e0ca                	sd	s2,64(sp)
    80001eec:	fc4e                	sd	s3,56(sp)
    80001eee:	f852                	sd	s4,48(sp)
    80001ef0:	f456                	sd	s5,40(sp)
    80001ef2:	f05a                	sd	s6,32(sp)
    80001ef4:	ec5e                	sd	s7,24(sp)
    80001ef6:	e862                	sd	s8,16(sp)
    80001ef8:	e466                	sd	s9,8(sp)
    80001efa:	1080                	addi	s0,sp,96
    80001efc:	8792                	mv	a5,tp
  int id = r_tp();
    80001efe:	2781                	sext.w	a5,a5
  c->proc = 0;
    80001f00:	00779b93          	slli	s7,a5,0x7
    80001f04:	0000f717          	auipc	a4,0xf
    80001f08:	39c70713          	addi	a4,a4,924 # 800112a0 <pid_lock>
    80001f0c:	975e                	add	a4,a4,s7
    80001f0e:	00073c23          	sd	zero,24(a4)
        swtch(&c->context, &p->context);
    80001f12:	0000f717          	auipc	a4,0xf
    80001f16:	3ae70713          	addi	a4,a4,942 # 800112c0 <cpus+0x8>
    80001f1a:	9bba                	add	s7,s7,a4
    int nproc = 0;
    80001f1c:	4c01                	li	s8,0
      if(p->state == RUNNABLE) {
    80001f1e:	4a89                	li	s5,2
        c->proc = p;
    80001f20:	079e                	slli	a5,a5,0x7
    80001f22:	0000fb17          	auipc	s6,0xf
    80001f26:	37eb0b13          	addi	s6,s6,894 # 800112a0 <pid_lock>
    80001f2a:	9b3e                	add	s6,s6,a5
    for(p = proc; p < &proc[NPROC]; p++) {
    80001f2c:	00010a17          	auipc	s4,0x10
    80001f30:	59ca0a13          	addi	s4,s4,1436 # 800124c8 <tickslock>
    80001f34:	a8a1                	j	80001f8c <scheduler+0xaa>
      release(&p->lock);
    80001f36:	8526                	mv	a0,s1
    80001f38:	fffff097          	auipc	ra,0xfffff
    80001f3c:	d3e080e7          	jalr	-706(ra) # 80000c76 <release>
    for(p = proc; p < &proc[NPROC]; p++) {
    80001f40:	16848493          	addi	s1,s1,360
    80001f44:	03448a63          	beq	s1,s4,80001f78 <scheduler+0x96>
      acquire(&p->lock);
    80001f48:	8526                	mv	a0,s1
    80001f4a:	fffff097          	auipc	ra,0xfffff
    80001f4e:	c78080e7          	jalr	-904(ra) # 80000bc2 <acquire>
      if(p->state != UNUSED) {
    80001f52:	4c9c                	lw	a5,24(s1)
    80001f54:	d3ed                	beqz	a5,80001f36 <scheduler+0x54>
        nproc++;
    80001f56:	2985                	addiw	s3,s3,1
      if(p->state == RUNNABLE) {
    80001f58:	fd579fe3          	bne	a5,s5,80001f36 <scheduler+0x54>
        p->state = RUNNING;
    80001f5c:	0194ac23          	sw	s9,24(s1)
        c->proc = p;
    80001f60:	009b3c23          	sd	s1,24(s6)
        swtch(&c->context, &p->context);
    80001f64:	06048593          	addi	a1,s1,96
    80001f68:	855e                	mv	a0,s7
    80001f6a:	00000097          	auipc	ra,0x0
    80001f6e:	60e080e7          	jalr	1550(ra) # 80002578 <swtch>
        c->proc = 0;
    80001f72:	000b3c23          	sd	zero,24(s6)
    80001f76:	b7c1                	j	80001f36 <scheduler+0x54>
    if(nproc <= 2) {   // only init and sh exist
    80001f78:	013aca63          	blt	s5,s3,80001f8c <scheduler+0xaa>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80001f7c:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80001f80:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80001f84:	10079073          	csrw	sstatus,a5
      asm volatile("wfi");
    80001f88:	10500073          	wfi
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80001f8c:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80001f90:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80001f94:	10079073          	csrw	sstatus,a5
    int nproc = 0;
    80001f98:	89e2                	mv	s3,s8
    for(p = proc; p < &proc[NPROC]; p++) {
    80001f9a:	0000f497          	auipc	s1,0xf
    80001f9e:	71e48493          	addi	s1,s1,1822 # 800116b8 <proc>
        p->state = RUNNING;
    80001fa2:	4c8d                	li	s9,3
    80001fa4:	b755                	j	80001f48 <scheduler+0x66>

0000000080001fa6 <sched>:
{
    80001fa6:	7179                	addi	sp,sp,-48
    80001fa8:	f406                	sd	ra,40(sp)
    80001faa:	f022                	sd	s0,32(sp)
    80001fac:	ec26                	sd	s1,24(sp)
    80001fae:	e84a                	sd	s2,16(sp)
    80001fb0:	e44e                	sd	s3,8(sp)
    80001fb2:	1800                	addi	s0,sp,48
  struct proc *p = myproc();
    80001fb4:	00000097          	auipc	ra,0x0
    80001fb8:	9f6080e7          	jalr	-1546(ra) # 800019aa <myproc>
    80001fbc:	84aa                	mv	s1,a0
  if(!holding(&p->lock))
    80001fbe:	fffff097          	auipc	ra,0xfffff
    80001fc2:	b8a080e7          	jalr	-1142(ra) # 80000b48 <holding>
    80001fc6:	c93d                	beqz	a0,8000203c <sched+0x96>
  asm volatile("mv %0, tp" : "=r" (x) );
    80001fc8:	8792                	mv	a5,tp
  if(mycpu()->noff != 1)
    80001fca:	2781                	sext.w	a5,a5
    80001fcc:	079e                	slli	a5,a5,0x7
    80001fce:	0000f717          	auipc	a4,0xf
    80001fd2:	2d270713          	addi	a4,a4,722 # 800112a0 <pid_lock>
    80001fd6:	97ba                	add	a5,a5,a4
    80001fd8:	0907a703          	lw	a4,144(a5)
    80001fdc:	4785                	li	a5,1
    80001fde:	06f71763          	bne	a4,a5,8000204c <sched+0xa6>
  if(p->state == RUNNING)
    80001fe2:	4c98                	lw	a4,24(s1)
    80001fe4:	478d                	li	a5,3
    80001fe6:	06f70b63          	beq	a4,a5,8000205c <sched+0xb6>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80001fea:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80001fee:	8b89                	andi	a5,a5,2
  if(intr_get())
    80001ff0:	efb5                	bnez	a5,8000206c <sched+0xc6>
  asm volatile("mv %0, tp" : "=r" (x) );
    80001ff2:	8792                	mv	a5,tp
  intena = mycpu()->intena;
    80001ff4:	0000f917          	auipc	s2,0xf
    80001ff8:	2ac90913          	addi	s2,s2,684 # 800112a0 <pid_lock>
    80001ffc:	2781                	sext.w	a5,a5
    80001ffe:	079e                	slli	a5,a5,0x7
    80002000:	97ca                	add	a5,a5,s2
    80002002:	0947a983          	lw	s3,148(a5)
    80002006:	8792                	mv	a5,tp
  swtch(&p->context, &mycpu()->context);
    80002008:	2781                	sext.w	a5,a5
    8000200a:	079e                	slli	a5,a5,0x7
    8000200c:	0000f597          	auipc	a1,0xf
    80002010:	2b458593          	addi	a1,a1,692 # 800112c0 <cpus+0x8>
    80002014:	95be                	add	a1,a1,a5
    80002016:	06048513          	addi	a0,s1,96
    8000201a:	00000097          	auipc	ra,0x0
    8000201e:	55e080e7          	jalr	1374(ra) # 80002578 <swtch>
    80002022:	8792                	mv	a5,tp
  mycpu()->intena = intena;
    80002024:	2781                	sext.w	a5,a5
    80002026:	079e                	slli	a5,a5,0x7
    80002028:	993e                	add	s2,s2,a5
    8000202a:	09392a23          	sw	s3,148(s2)
}
    8000202e:	70a2                	ld	ra,40(sp)
    80002030:	7402                	ld	s0,32(sp)
    80002032:	64e2                	ld	s1,24(sp)
    80002034:	6942                	ld	s2,16(sp)
    80002036:	69a2                	ld	s3,8(sp)
    80002038:	6145                	addi	sp,sp,48
    8000203a:	8082                	ret
    panic("sched p->lock");
    8000203c:	00006517          	auipc	a0,0x6
    80002040:	1bc50513          	addi	a0,a0,444 # 800081f8 <digits+0x1b8>
    80002044:	ffffe097          	auipc	ra,0xffffe
    80002048:	4e8080e7          	jalr	1256(ra) # 8000052c <panic>
    panic("sched locks");
    8000204c:	00006517          	auipc	a0,0x6
    80002050:	1bc50513          	addi	a0,a0,444 # 80008208 <digits+0x1c8>
    80002054:	ffffe097          	auipc	ra,0xffffe
    80002058:	4d8080e7          	jalr	1240(ra) # 8000052c <panic>
    panic("sched running");
    8000205c:	00006517          	auipc	a0,0x6
    80002060:	1bc50513          	addi	a0,a0,444 # 80008218 <digits+0x1d8>
    80002064:	ffffe097          	auipc	ra,0xffffe
    80002068:	4c8080e7          	jalr	1224(ra) # 8000052c <panic>
    panic("sched interruptible");
    8000206c:	00006517          	auipc	a0,0x6
    80002070:	1bc50513          	addi	a0,a0,444 # 80008228 <digits+0x1e8>
    80002074:	ffffe097          	auipc	ra,0xffffe
    80002078:	4b8080e7          	jalr	1208(ra) # 8000052c <panic>

000000008000207c <exit>:
{
    8000207c:	7179                	addi	sp,sp,-48
    8000207e:	f406                	sd	ra,40(sp)
    80002080:	f022                	sd	s0,32(sp)
    80002082:	ec26                	sd	s1,24(sp)
    80002084:	e84a                	sd	s2,16(sp)
    80002086:	e44e                	sd	s3,8(sp)
    80002088:	e052                	sd	s4,0(sp)
    8000208a:	1800                	addi	s0,sp,48
    8000208c:	8a2a                	mv	s4,a0
  struct proc *p = myproc();
    8000208e:	00000097          	auipc	ra,0x0
    80002092:	91c080e7          	jalr	-1764(ra) # 800019aa <myproc>
    80002096:	89aa                	mv	s3,a0
  if(p == initproc)
    80002098:	00007797          	auipc	a5,0x7
    8000209c:	f907b783          	ld	a5,-112(a5) # 80009028 <initproc>
    800020a0:	0d050493          	addi	s1,a0,208
    800020a4:	15050913          	addi	s2,a0,336
    800020a8:	02a79363          	bne	a5,a0,800020ce <exit+0x52>
    panic("init exiting");
    800020ac:	00006517          	auipc	a0,0x6
    800020b0:	19450513          	addi	a0,a0,404 # 80008240 <digits+0x200>
    800020b4:	ffffe097          	auipc	ra,0xffffe
    800020b8:	478080e7          	jalr	1144(ra) # 8000052c <panic>
      fileclose(f);
    800020bc:	00002097          	auipc	ra,0x2
    800020c0:	5a2080e7          	jalr	1442(ra) # 8000465e <fileclose>
      p->ofile[fd] = 0;
    800020c4:	0004b023          	sd	zero,0(s1)
  for(int fd = 0; fd < NOFILE; fd++){
    800020c8:	04a1                	addi	s1,s1,8
    800020ca:	01248563          	beq	s1,s2,800020d4 <exit+0x58>
    if(p->ofile[fd]){
    800020ce:	6088                	ld	a0,0(s1)
    800020d0:	f575                	bnez	a0,800020bc <exit+0x40>
    800020d2:	bfdd                	j	800020c8 <exit+0x4c>
  begin_op();
    800020d4:	00002097          	auipc	ra,0x2
    800020d8:	0ba080e7          	jalr	186(ra) # 8000418e <begin_op>
  iput(p->cwd);
    800020dc:	1509b503          	ld	a0,336(s3)
    800020e0:	00002097          	auipc	ra,0x2
    800020e4:	824080e7          	jalr	-2012(ra) # 80003904 <iput>
  end_op();
    800020e8:	00002097          	auipc	ra,0x2
    800020ec:	124080e7          	jalr	292(ra) # 8000420c <end_op>
  p->cwd = 0;
    800020f0:	1409b823          	sd	zero,336(s3)
  acquire(&initproc->lock);
    800020f4:	00007497          	auipc	s1,0x7
    800020f8:	f3448493          	addi	s1,s1,-204 # 80009028 <initproc>
    800020fc:	6088                	ld	a0,0(s1)
    800020fe:	fffff097          	auipc	ra,0xfffff
    80002102:	ac4080e7          	jalr	-1340(ra) # 80000bc2 <acquire>
  wakeup1(initproc);
    80002106:	6088                	ld	a0,0(s1)
    80002108:	fffff097          	auipc	ra,0xfffff
    8000210c:	704080e7          	jalr	1796(ra) # 8000180c <wakeup1>
  release(&initproc->lock);
    80002110:	6088                	ld	a0,0(s1)
    80002112:	fffff097          	auipc	ra,0xfffff
    80002116:	b64080e7          	jalr	-1180(ra) # 80000c76 <release>
  acquire(&p->lock);
    8000211a:	854e                	mv	a0,s3
    8000211c:	fffff097          	auipc	ra,0xfffff
    80002120:	aa6080e7          	jalr	-1370(ra) # 80000bc2 <acquire>
  struct proc *original_parent = p->parent;
    80002124:	0209b483          	ld	s1,32(s3)
  release(&p->lock);
    80002128:	854e                	mv	a0,s3
    8000212a:	fffff097          	auipc	ra,0xfffff
    8000212e:	b4c080e7          	jalr	-1204(ra) # 80000c76 <release>
  acquire(&original_parent->lock);
    80002132:	8526                	mv	a0,s1
    80002134:	fffff097          	auipc	ra,0xfffff
    80002138:	a8e080e7          	jalr	-1394(ra) # 80000bc2 <acquire>
  acquire(&p->lock);
    8000213c:	854e                	mv	a0,s3
    8000213e:	fffff097          	auipc	ra,0xfffff
    80002142:	a84080e7          	jalr	-1404(ra) # 80000bc2 <acquire>
  reparent(p);
    80002146:	854e                	mv	a0,s3
    80002148:	00000097          	auipc	ra,0x0
    8000214c:	d34080e7          	jalr	-716(ra) # 80001e7c <reparent>
  wakeup1(original_parent);
    80002150:	8526                	mv	a0,s1
    80002152:	fffff097          	auipc	ra,0xfffff
    80002156:	6ba080e7          	jalr	1722(ra) # 8000180c <wakeup1>
  p->xstate = status;
    8000215a:	0349aa23          	sw	s4,52(s3)
  p->state = ZOMBIE;
    8000215e:	4791                	li	a5,4
    80002160:	00f9ac23          	sw	a5,24(s3)
  release(&original_parent->lock);
    80002164:	8526                	mv	a0,s1
    80002166:	fffff097          	auipc	ra,0xfffff
    8000216a:	b10080e7          	jalr	-1264(ra) # 80000c76 <release>
  sched();
    8000216e:	00000097          	auipc	ra,0x0
    80002172:	e38080e7          	jalr	-456(ra) # 80001fa6 <sched>
  panic("zombie exit");
    80002176:	00006517          	auipc	a0,0x6
    8000217a:	0da50513          	addi	a0,a0,218 # 80008250 <digits+0x210>
    8000217e:	ffffe097          	auipc	ra,0xffffe
    80002182:	3ae080e7          	jalr	942(ra) # 8000052c <panic>

0000000080002186 <yield>:
{
    80002186:	1101                	addi	sp,sp,-32
    80002188:	ec06                	sd	ra,24(sp)
    8000218a:	e822                	sd	s0,16(sp)
    8000218c:	e426                	sd	s1,8(sp)
    8000218e:	1000                	addi	s0,sp,32
  struct proc *p = myproc();
    80002190:	00000097          	auipc	ra,0x0
    80002194:	81a080e7          	jalr	-2022(ra) # 800019aa <myproc>
    80002198:	84aa                	mv	s1,a0
  acquire(&p->lock);
    8000219a:	fffff097          	auipc	ra,0xfffff
    8000219e:	a28080e7          	jalr	-1496(ra) # 80000bc2 <acquire>
  p->state = RUNNABLE;
    800021a2:	4789                	li	a5,2
    800021a4:	cc9c                	sw	a5,24(s1)
  sched();
    800021a6:	00000097          	auipc	ra,0x0
    800021aa:	e00080e7          	jalr	-512(ra) # 80001fa6 <sched>
  release(&p->lock);
    800021ae:	8526                	mv	a0,s1
    800021b0:	fffff097          	auipc	ra,0xfffff
    800021b4:	ac6080e7          	jalr	-1338(ra) # 80000c76 <release>
}
    800021b8:	60e2                	ld	ra,24(sp)
    800021ba:	6442                	ld	s0,16(sp)
    800021bc:	64a2                	ld	s1,8(sp)
    800021be:	6105                	addi	sp,sp,32
    800021c0:	8082                	ret

00000000800021c2 <sleep>:
{
    800021c2:	7179                	addi	sp,sp,-48
    800021c4:	f406                	sd	ra,40(sp)
    800021c6:	f022                	sd	s0,32(sp)
    800021c8:	ec26                	sd	s1,24(sp)
    800021ca:	e84a                	sd	s2,16(sp)
    800021cc:	e44e                	sd	s3,8(sp)
    800021ce:	1800                	addi	s0,sp,48
    800021d0:	89aa                	mv	s3,a0
    800021d2:	892e                	mv	s2,a1
  struct proc *p = myproc();
    800021d4:	fffff097          	auipc	ra,0xfffff
    800021d8:	7d6080e7          	jalr	2006(ra) # 800019aa <myproc>
    800021dc:	84aa                	mv	s1,a0
  if(lk != &p->lock){  //DOC: sleeplock0
    800021de:	05250663          	beq	a0,s2,8000222a <sleep+0x68>
    acquire(&p->lock);  //DOC: sleeplock1
    800021e2:	fffff097          	auipc	ra,0xfffff
    800021e6:	9e0080e7          	jalr	-1568(ra) # 80000bc2 <acquire>
    release(lk);
    800021ea:	854a                	mv	a0,s2
    800021ec:	fffff097          	auipc	ra,0xfffff
    800021f0:	a8a080e7          	jalr	-1398(ra) # 80000c76 <release>
  p->chan = chan;
    800021f4:	0334b423          	sd	s3,40(s1)
  p->state = SLEEPING;
    800021f8:	4785                	li	a5,1
    800021fa:	cc9c                	sw	a5,24(s1)
  sched();
    800021fc:	00000097          	auipc	ra,0x0
    80002200:	daa080e7          	jalr	-598(ra) # 80001fa6 <sched>
  p->chan = 0;
    80002204:	0204b423          	sd	zero,40(s1)
    release(&p->lock);
    80002208:	8526                	mv	a0,s1
    8000220a:	fffff097          	auipc	ra,0xfffff
    8000220e:	a6c080e7          	jalr	-1428(ra) # 80000c76 <release>
    acquire(lk);
    80002212:	854a                	mv	a0,s2
    80002214:	fffff097          	auipc	ra,0xfffff
    80002218:	9ae080e7          	jalr	-1618(ra) # 80000bc2 <acquire>
}
    8000221c:	70a2                	ld	ra,40(sp)
    8000221e:	7402                	ld	s0,32(sp)
    80002220:	64e2                	ld	s1,24(sp)
    80002222:	6942                	ld	s2,16(sp)
    80002224:	69a2                	ld	s3,8(sp)
    80002226:	6145                	addi	sp,sp,48
    80002228:	8082                	ret
  p->chan = chan;
    8000222a:	03353423          	sd	s3,40(a0)
  p->state = SLEEPING;
    8000222e:	4785                	li	a5,1
    80002230:	cd1c                	sw	a5,24(a0)
  sched();
    80002232:	00000097          	auipc	ra,0x0
    80002236:	d74080e7          	jalr	-652(ra) # 80001fa6 <sched>
  p->chan = 0;
    8000223a:	0204b423          	sd	zero,40(s1)
  if(lk != &p->lock){
    8000223e:	bff9                	j	8000221c <sleep+0x5a>

0000000080002240 <wait>:
{
    80002240:	715d                	addi	sp,sp,-80
    80002242:	e486                	sd	ra,72(sp)
    80002244:	e0a2                	sd	s0,64(sp)
    80002246:	fc26                	sd	s1,56(sp)
    80002248:	f84a                	sd	s2,48(sp)
    8000224a:	f44e                	sd	s3,40(sp)
    8000224c:	f052                	sd	s4,32(sp)
    8000224e:	ec56                	sd	s5,24(sp)
    80002250:	e85a                	sd	s6,16(sp)
    80002252:	e45e                	sd	s7,8(sp)
    80002254:	0880                	addi	s0,sp,80
    80002256:	8aaa                	mv	s5,a0
  struct proc *p = myproc();
    80002258:	fffff097          	auipc	ra,0xfffff
    8000225c:	752080e7          	jalr	1874(ra) # 800019aa <myproc>
    80002260:	892a                	mv	s2,a0
  acquire(&p->lock);
    80002262:	fffff097          	auipc	ra,0xfffff
    80002266:	960080e7          	jalr	-1696(ra) # 80000bc2 <acquire>
    havekids = 0;
    8000226a:	4b81                	li	s7,0
        if(np->state == ZOMBIE){
    8000226c:	4a11                	li	s4,4
        havekids = 1;
    8000226e:	4b05                	li	s6,1
    for(np = proc; np < &proc[NPROC]; np++){
    80002270:	00010997          	auipc	s3,0x10
    80002274:	25898993          	addi	s3,s3,600 # 800124c8 <tickslock>
    havekids = 0;
    80002278:	875e                	mv	a4,s7
    for(np = proc; np < &proc[NPROC]; np++){
    8000227a:	0000f497          	auipc	s1,0xf
    8000227e:	43e48493          	addi	s1,s1,1086 # 800116b8 <proc>
    80002282:	a08d                	j	800022e4 <wait+0xa4>
          pid = np->pid;
    80002284:	0384a983          	lw	s3,56(s1)
          if(addr != 0 && copyout(p->pagetable, addr, (char *)&np->xstate,
    80002288:	000a8e63          	beqz	s5,800022a4 <wait+0x64>
    8000228c:	4691                	li	a3,4
    8000228e:	03448613          	addi	a2,s1,52
    80002292:	85d6                	mv	a1,s5
    80002294:	05093503          	ld	a0,80(s2)
    80002298:	fffff097          	auipc	ra,0xfffff
    8000229c:	3aa080e7          	jalr	938(ra) # 80001642 <copyout>
    800022a0:	02054263          	bltz	a0,800022c4 <wait+0x84>
          freeproc(np);
    800022a4:	8526                	mv	a0,s1
    800022a6:	00000097          	auipc	ra,0x0
    800022aa:	8b6080e7          	jalr	-1866(ra) # 80001b5c <freeproc>
          release(&np->lock);
    800022ae:	8526                	mv	a0,s1
    800022b0:	fffff097          	auipc	ra,0xfffff
    800022b4:	9c6080e7          	jalr	-1594(ra) # 80000c76 <release>
          release(&p->lock);
    800022b8:	854a                	mv	a0,s2
    800022ba:	fffff097          	auipc	ra,0xfffff
    800022be:	9bc080e7          	jalr	-1604(ra) # 80000c76 <release>
          return pid;
    800022c2:	a8a9                	j	8000231c <wait+0xdc>
            release(&np->lock);
    800022c4:	8526                	mv	a0,s1
    800022c6:	fffff097          	auipc	ra,0xfffff
    800022ca:	9b0080e7          	jalr	-1616(ra) # 80000c76 <release>
            release(&p->lock);
    800022ce:	854a                	mv	a0,s2
    800022d0:	fffff097          	auipc	ra,0xfffff
    800022d4:	9a6080e7          	jalr	-1626(ra) # 80000c76 <release>
            return -1;
    800022d8:	59fd                	li	s3,-1
    800022da:	a089                	j	8000231c <wait+0xdc>
    for(np = proc; np < &proc[NPROC]; np++){
    800022dc:	16848493          	addi	s1,s1,360
    800022e0:	03348463          	beq	s1,s3,80002308 <wait+0xc8>
      if(np->parent == p){
    800022e4:	709c                	ld	a5,32(s1)
    800022e6:	ff279be3          	bne	a5,s2,800022dc <wait+0x9c>
        acquire(&np->lock);
    800022ea:	8526                	mv	a0,s1
    800022ec:	fffff097          	auipc	ra,0xfffff
    800022f0:	8d6080e7          	jalr	-1834(ra) # 80000bc2 <acquire>
        if(np->state == ZOMBIE){
    800022f4:	4c9c                	lw	a5,24(s1)
    800022f6:	f94787e3          	beq	a5,s4,80002284 <wait+0x44>
        release(&np->lock);
    800022fa:	8526                	mv	a0,s1
    800022fc:	fffff097          	auipc	ra,0xfffff
    80002300:	97a080e7          	jalr	-1670(ra) # 80000c76 <release>
        havekids = 1;
    80002304:	875a                	mv	a4,s6
    80002306:	bfd9                	j	800022dc <wait+0x9c>
    if(!havekids || p->killed){
    80002308:	c701                	beqz	a4,80002310 <wait+0xd0>
    8000230a:	03092783          	lw	a5,48(s2)
    8000230e:	c39d                	beqz	a5,80002334 <wait+0xf4>
      release(&p->lock);
    80002310:	854a                	mv	a0,s2
    80002312:	fffff097          	auipc	ra,0xfffff
    80002316:	964080e7          	jalr	-1692(ra) # 80000c76 <release>
      return -1;
    8000231a:	59fd                	li	s3,-1
}
    8000231c:	854e                	mv	a0,s3
    8000231e:	60a6                	ld	ra,72(sp)
    80002320:	6406                	ld	s0,64(sp)
    80002322:	74e2                	ld	s1,56(sp)
    80002324:	7942                	ld	s2,48(sp)
    80002326:	79a2                	ld	s3,40(sp)
    80002328:	7a02                	ld	s4,32(sp)
    8000232a:	6ae2                	ld	s5,24(sp)
    8000232c:	6b42                	ld	s6,16(sp)
    8000232e:	6ba2                	ld	s7,8(sp)
    80002330:	6161                	addi	sp,sp,80
    80002332:	8082                	ret
    sleep(p, &p->lock);  //DOC: wait-sleep
    80002334:	85ca                	mv	a1,s2
    80002336:	854a                	mv	a0,s2
    80002338:	00000097          	auipc	ra,0x0
    8000233c:	e8a080e7          	jalr	-374(ra) # 800021c2 <sleep>
    havekids = 0;
    80002340:	bf25                	j	80002278 <wait+0x38>

0000000080002342 <wakeup>:
{
    80002342:	7139                	addi	sp,sp,-64
    80002344:	fc06                	sd	ra,56(sp)
    80002346:	f822                	sd	s0,48(sp)
    80002348:	f426                	sd	s1,40(sp)
    8000234a:	f04a                	sd	s2,32(sp)
    8000234c:	ec4e                	sd	s3,24(sp)
    8000234e:	e852                	sd	s4,16(sp)
    80002350:	e456                	sd	s5,8(sp)
    80002352:	0080                	addi	s0,sp,64
    80002354:	8a2a                	mv	s4,a0
  for(p = proc; p < &proc[NPROC]; p++) {
    80002356:	0000f497          	auipc	s1,0xf
    8000235a:	36248493          	addi	s1,s1,866 # 800116b8 <proc>
    if(p->state == SLEEPING && p->chan == chan) {
    8000235e:	4985                	li	s3,1
      p->state = RUNNABLE;
    80002360:	4a89                	li	s5,2
  for(p = proc; p < &proc[NPROC]; p++) {
    80002362:	00010917          	auipc	s2,0x10
    80002366:	16690913          	addi	s2,s2,358 # 800124c8 <tickslock>
    8000236a:	a811                	j	8000237e <wakeup+0x3c>
    release(&p->lock);
    8000236c:	8526                	mv	a0,s1
    8000236e:	fffff097          	auipc	ra,0xfffff
    80002372:	908080e7          	jalr	-1784(ra) # 80000c76 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    80002376:	16848493          	addi	s1,s1,360
    8000237a:	03248063          	beq	s1,s2,8000239a <wakeup+0x58>
    acquire(&p->lock);
    8000237e:	8526                	mv	a0,s1
    80002380:	fffff097          	auipc	ra,0xfffff
    80002384:	842080e7          	jalr	-1982(ra) # 80000bc2 <acquire>
    if(p->state == SLEEPING && p->chan == chan) {
    80002388:	4c9c                	lw	a5,24(s1)
    8000238a:	ff3791e3          	bne	a5,s3,8000236c <wakeup+0x2a>
    8000238e:	749c                	ld	a5,40(s1)
    80002390:	fd479ee3          	bne	a5,s4,8000236c <wakeup+0x2a>
      p->state = RUNNABLE;
    80002394:	0154ac23          	sw	s5,24(s1)
    80002398:	bfd1                	j	8000236c <wakeup+0x2a>
}
    8000239a:	70e2                	ld	ra,56(sp)
    8000239c:	7442                	ld	s0,48(sp)
    8000239e:	74a2                	ld	s1,40(sp)
    800023a0:	7902                	ld	s2,32(sp)
    800023a2:	69e2                	ld	s3,24(sp)
    800023a4:	6a42                	ld	s4,16(sp)
    800023a6:	6aa2                	ld	s5,8(sp)
    800023a8:	6121                	addi	sp,sp,64
    800023aa:	8082                	ret

00000000800023ac <kill>:
// Kill the process with the given pid.
// The victim won't exit until it tries to return
// to user space (see usertrap() in trap.c).
int
kill(int pid)
{
    800023ac:	7179                	addi	sp,sp,-48
    800023ae:	f406                	sd	ra,40(sp)
    800023b0:	f022                	sd	s0,32(sp)
    800023b2:	ec26                	sd	s1,24(sp)
    800023b4:	e84a                	sd	s2,16(sp)
    800023b6:	e44e                	sd	s3,8(sp)
    800023b8:	1800                	addi	s0,sp,48
    800023ba:	892a                	mv	s2,a0
  struct proc *p;

  for(p = proc; p < &proc[NPROC]; p++){
    800023bc:	0000f497          	auipc	s1,0xf
    800023c0:	2fc48493          	addi	s1,s1,764 # 800116b8 <proc>
    800023c4:	00010997          	auipc	s3,0x10
    800023c8:	10498993          	addi	s3,s3,260 # 800124c8 <tickslock>
    acquire(&p->lock);
    800023cc:	8526                	mv	a0,s1
    800023ce:	ffffe097          	auipc	ra,0xffffe
    800023d2:	7f4080e7          	jalr	2036(ra) # 80000bc2 <acquire>
    if(p->pid == pid){
    800023d6:	5c9c                	lw	a5,56(s1)
    800023d8:	03278363          	beq	a5,s2,800023fe <kill+0x52>
        p->state = RUNNABLE;
      }
      release(&p->lock);
      return 0;
    }
    release(&p->lock);
    800023dc:	8526                	mv	a0,s1
    800023de:	fffff097          	auipc	ra,0xfffff
    800023e2:	898080e7          	jalr	-1896(ra) # 80000c76 <release>
  for(p = proc; p < &proc[NPROC]; p++){
    800023e6:	16848493          	addi	s1,s1,360
    800023ea:	ff3491e3          	bne	s1,s3,800023cc <kill+0x20>
  }
  return -1;
    800023ee:	557d                	li	a0,-1
}
    800023f0:	70a2                	ld	ra,40(sp)
    800023f2:	7402                	ld	s0,32(sp)
    800023f4:	64e2                	ld	s1,24(sp)
    800023f6:	6942                	ld	s2,16(sp)
    800023f8:	69a2                	ld	s3,8(sp)
    800023fa:	6145                	addi	sp,sp,48
    800023fc:	8082                	ret
      p->killed = 1;
    800023fe:	4785                	li	a5,1
    80002400:	d89c                	sw	a5,48(s1)
      if(p->state == SLEEPING){
    80002402:	4c98                	lw	a4,24(s1)
    80002404:	00f70963          	beq	a4,a5,80002416 <kill+0x6a>
      release(&p->lock);
    80002408:	8526                	mv	a0,s1
    8000240a:	fffff097          	auipc	ra,0xfffff
    8000240e:	86c080e7          	jalr	-1940(ra) # 80000c76 <release>
      return 0;
    80002412:	4501                	li	a0,0
    80002414:	bff1                	j	800023f0 <kill+0x44>
        p->state = RUNNABLE;
    80002416:	4789                	li	a5,2
    80002418:	cc9c                	sw	a5,24(s1)
    8000241a:	b7fd                	j	80002408 <kill+0x5c>

000000008000241c <either_copyout>:
// Copy to either a user address, or kernel address,
// depending on usr_dst.
// Returns 0 on success, -1 on error.
int
either_copyout(int user_dst, uint64 dst, void *src, uint64 len)
{
    8000241c:	7179                	addi	sp,sp,-48
    8000241e:	f406                	sd	ra,40(sp)
    80002420:	f022                	sd	s0,32(sp)
    80002422:	ec26                	sd	s1,24(sp)
    80002424:	e84a                	sd	s2,16(sp)
    80002426:	e44e                	sd	s3,8(sp)
    80002428:	e052                	sd	s4,0(sp)
    8000242a:	1800                	addi	s0,sp,48
    8000242c:	84aa                	mv	s1,a0
    8000242e:	892e                	mv	s2,a1
    80002430:	89b2                	mv	s3,a2
    80002432:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    80002434:	fffff097          	auipc	ra,0xfffff
    80002438:	576080e7          	jalr	1398(ra) # 800019aa <myproc>
  if(user_dst){
    8000243c:	c08d                	beqz	s1,8000245e <either_copyout+0x42>
    return copyout(p->pagetable, dst, src, len);
    8000243e:	86d2                	mv	a3,s4
    80002440:	864e                	mv	a2,s3
    80002442:	85ca                	mv	a1,s2
    80002444:	6928                	ld	a0,80(a0)
    80002446:	fffff097          	auipc	ra,0xfffff
    8000244a:	1fc080e7          	jalr	508(ra) # 80001642 <copyout>
  } else {
    memmove((char *)dst, src, len);
    return 0;
  }
}
    8000244e:	70a2                	ld	ra,40(sp)
    80002450:	7402                	ld	s0,32(sp)
    80002452:	64e2                	ld	s1,24(sp)
    80002454:	6942                	ld	s2,16(sp)
    80002456:	69a2                	ld	s3,8(sp)
    80002458:	6a02                	ld	s4,0(sp)
    8000245a:	6145                	addi	sp,sp,48
    8000245c:	8082                	ret
    memmove((char *)dst, src, len);
    8000245e:	000a061b          	sext.w	a2,s4
    80002462:	85ce                	mv	a1,s3
    80002464:	854a                	mv	a0,s2
    80002466:	fffff097          	auipc	ra,0xfffff
    8000246a:	8b4080e7          	jalr	-1868(ra) # 80000d1a <memmove>
    return 0;
    8000246e:	8526                	mv	a0,s1
    80002470:	bff9                	j	8000244e <either_copyout+0x32>

0000000080002472 <either_copyin>:
// Copy from either a user address, or kernel address,
// depending on usr_src.
// Returns 0 on success, -1 on error.
int
either_copyin(void *dst, int user_src, uint64 src, uint64 len)
{
    80002472:	7179                	addi	sp,sp,-48
    80002474:	f406                	sd	ra,40(sp)
    80002476:	f022                	sd	s0,32(sp)
    80002478:	ec26                	sd	s1,24(sp)
    8000247a:	e84a                	sd	s2,16(sp)
    8000247c:	e44e                	sd	s3,8(sp)
    8000247e:	e052                	sd	s4,0(sp)
    80002480:	1800                	addi	s0,sp,48
    80002482:	892a                	mv	s2,a0
    80002484:	84ae                	mv	s1,a1
    80002486:	89b2                	mv	s3,a2
    80002488:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    8000248a:	fffff097          	auipc	ra,0xfffff
    8000248e:	520080e7          	jalr	1312(ra) # 800019aa <myproc>
  if(user_src){
    80002492:	c08d                	beqz	s1,800024b4 <either_copyin+0x42>
    return copyin(p->pagetable, dst, src, len);
    80002494:	86d2                	mv	a3,s4
    80002496:	864e                	mv	a2,s3
    80002498:	85ca                	mv	a1,s2
    8000249a:	6928                	ld	a0,80(a0)
    8000249c:	fffff097          	auipc	ra,0xfffff
    800024a0:	232080e7          	jalr	562(ra) # 800016ce <copyin>
  } else {
    memmove(dst, (char*)src, len);
    return 0;
  }
}
    800024a4:	70a2                	ld	ra,40(sp)
    800024a6:	7402                	ld	s0,32(sp)
    800024a8:	64e2                	ld	s1,24(sp)
    800024aa:	6942                	ld	s2,16(sp)
    800024ac:	69a2                	ld	s3,8(sp)
    800024ae:	6a02                	ld	s4,0(sp)
    800024b0:	6145                	addi	sp,sp,48
    800024b2:	8082                	ret
    memmove(dst, (char*)src, len);
    800024b4:	000a061b          	sext.w	a2,s4
    800024b8:	85ce                	mv	a1,s3
    800024ba:	854a                	mv	a0,s2
    800024bc:	fffff097          	auipc	ra,0xfffff
    800024c0:	85e080e7          	jalr	-1954(ra) # 80000d1a <memmove>
    return 0;
    800024c4:	8526                	mv	a0,s1
    800024c6:	bff9                	j	800024a4 <either_copyin+0x32>

00000000800024c8 <procdump>:
// Print a process listing to console.  For debugging.
// Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further.
void
procdump(void)
{
    800024c8:	715d                	addi	sp,sp,-80
    800024ca:	e486                	sd	ra,72(sp)
    800024cc:	e0a2                	sd	s0,64(sp)
    800024ce:	fc26                	sd	s1,56(sp)
    800024d0:	f84a                	sd	s2,48(sp)
    800024d2:	f44e                	sd	s3,40(sp)
    800024d4:	f052                	sd	s4,32(sp)
    800024d6:	ec56                	sd	s5,24(sp)
    800024d8:	e85a                	sd	s6,16(sp)
    800024da:	e45e                	sd	s7,8(sp)
    800024dc:	0880                	addi	s0,sp,80
  [ZOMBIE]    "zombie"
  };
  struct proc *p;
  char *state;

  printf("\n");
    800024de:	00006517          	auipc	a0,0x6
    800024e2:	bea50513          	addi	a0,a0,-1046 # 800080c8 <digits+0x88>
    800024e6:	ffffe097          	auipc	ra,0xffffe
    800024ea:	090080e7          	jalr	144(ra) # 80000576 <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    800024ee:	0000f497          	auipc	s1,0xf
    800024f2:	32248493          	addi	s1,s1,802 # 80011810 <proc+0x158>
    800024f6:	00010917          	auipc	s2,0x10
    800024fa:	12a90913          	addi	s2,s2,298 # 80012620 <bcache+0x140>
    if(p->state == UNUSED)
      continue;
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    800024fe:	4b11                	li	s6,4
      state = states[p->state];
    else
      state = "???";
    80002500:	00006997          	auipc	s3,0x6
    80002504:	d6098993          	addi	s3,s3,-672 # 80008260 <digits+0x220>
    printf("%d %s %s", p->pid, state, p->name);
    80002508:	00006a97          	auipc	s5,0x6
    8000250c:	d60a8a93          	addi	s5,s5,-672 # 80008268 <digits+0x228>
    printf("\n");
    80002510:	00006a17          	auipc	s4,0x6
    80002514:	bb8a0a13          	addi	s4,s4,-1096 # 800080c8 <digits+0x88>
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    80002518:	00006b97          	auipc	s7,0x6
    8000251c:	d88b8b93          	addi	s7,s7,-632 # 800082a0 <states.0>
    80002520:	a00d                	j	80002542 <procdump+0x7a>
    printf("%d %s %s", p->pid, state, p->name);
    80002522:	ee06a583          	lw	a1,-288(a3)
    80002526:	8556                	mv	a0,s5
    80002528:	ffffe097          	auipc	ra,0xffffe
    8000252c:	04e080e7          	jalr	78(ra) # 80000576 <printf>
    printf("\n");
    80002530:	8552                	mv	a0,s4
    80002532:	ffffe097          	auipc	ra,0xffffe
    80002536:	044080e7          	jalr	68(ra) # 80000576 <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    8000253a:	16848493          	addi	s1,s1,360
    8000253e:	03248263          	beq	s1,s2,80002562 <procdump+0x9a>
    if(p->state == UNUSED)
    80002542:	86a6                	mv	a3,s1
    80002544:	ec04a783          	lw	a5,-320(s1)
    80002548:	dbed                	beqz	a5,8000253a <procdump+0x72>
      state = "???";
    8000254a:	864e                	mv	a2,s3
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    8000254c:	fcfb6be3          	bltu	s6,a5,80002522 <procdump+0x5a>
    80002550:	02079713          	slli	a4,a5,0x20
    80002554:	01d75793          	srli	a5,a4,0x1d
    80002558:	97de                	add	a5,a5,s7
    8000255a:	6390                	ld	a2,0(a5)
    8000255c:	f279                	bnez	a2,80002522 <procdump+0x5a>
      state = "???";
    8000255e:	864e                	mv	a2,s3
    80002560:	b7c9                	j	80002522 <procdump+0x5a>
  }
}
    80002562:	60a6                	ld	ra,72(sp)
    80002564:	6406                	ld	s0,64(sp)
    80002566:	74e2                	ld	s1,56(sp)
    80002568:	7942                	ld	s2,48(sp)
    8000256a:	79a2                	ld	s3,40(sp)
    8000256c:	7a02                	ld	s4,32(sp)
    8000256e:	6ae2                	ld	s5,24(sp)
    80002570:	6b42                	ld	s6,16(sp)
    80002572:	6ba2                	ld	s7,8(sp)
    80002574:	6161                	addi	sp,sp,80
    80002576:	8082                	ret

0000000080002578 <swtch>:
    80002578:	00153023          	sd	ra,0(a0)
    8000257c:	00253423          	sd	sp,8(a0)
    80002580:	e900                	sd	s0,16(a0)
    80002582:	ed04                	sd	s1,24(a0)
    80002584:	03253023          	sd	s2,32(a0)
    80002588:	03353423          	sd	s3,40(a0)
    8000258c:	03453823          	sd	s4,48(a0)
    80002590:	03553c23          	sd	s5,56(a0)
    80002594:	05653023          	sd	s6,64(a0)
    80002598:	05753423          	sd	s7,72(a0)
    8000259c:	05853823          	sd	s8,80(a0)
    800025a0:	05953c23          	sd	s9,88(a0)
    800025a4:	07a53023          	sd	s10,96(a0)
    800025a8:	07b53423          	sd	s11,104(a0)
    800025ac:	0005b083          	ld	ra,0(a1)
    800025b0:	0085b103          	ld	sp,8(a1)
    800025b4:	6980                	ld	s0,16(a1)
    800025b6:	6d84                	ld	s1,24(a1)
    800025b8:	0205b903          	ld	s2,32(a1)
    800025bc:	0285b983          	ld	s3,40(a1)
    800025c0:	0305ba03          	ld	s4,48(a1)
    800025c4:	0385ba83          	ld	s5,56(a1)
    800025c8:	0405bb03          	ld	s6,64(a1)
    800025cc:	0485bb83          	ld	s7,72(a1)
    800025d0:	0505bc03          	ld	s8,80(a1)
    800025d4:	0585bc83          	ld	s9,88(a1)
    800025d8:	0605bd03          	ld	s10,96(a1)
    800025dc:	0685bd83          	ld	s11,104(a1)
    800025e0:	8082                	ret

00000000800025e2 <trapinit>:

extern int devintr();

void
trapinit(void)
{
    800025e2:	1141                	addi	sp,sp,-16
    800025e4:	e406                	sd	ra,8(sp)
    800025e6:	e022                	sd	s0,0(sp)
    800025e8:	0800                	addi	s0,sp,16
  initlock(&tickslock, "time");
    800025ea:	00006597          	auipc	a1,0x6
    800025ee:	cde58593          	addi	a1,a1,-802 # 800082c8 <states.0+0x28>
    800025f2:	00010517          	auipc	a0,0x10
    800025f6:	ed650513          	addi	a0,a0,-298 # 800124c8 <tickslock>
    800025fa:	ffffe097          	auipc	ra,0xffffe
    800025fe:	538080e7          	jalr	1336(ra) # 80000b32 <initlock>
}
    80002602:	60a2                	ld	ra,8(sp)
    80002604:	6402                	ld	s0,0(sp)
    80002606:	0141                	addi	sp,sp,16
    80002608:	8082                	ret

000000008000260a <trapinithart>:

// set up to take exceptions and traps while in the kernel.
void
trapinithart(void)
{
    8000260a:	1141                	addi	sp,sp,-16
    8000260c:	e422                	sd	s0,8(sp)
    8000260e:	0800                	addi	s0,sp,16
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002610:	00003797          	auipc	a5,0x3
    80002614:	70078793          	addi	a5,a5,1792 # 80005d10 <kernelvec>
    80002618:	10579073          	csrw	stvec,a5
  w_stvec((uint64)kernelvec);
}
    8000261c:	6422                	ld	s0,8(sp)
    8000261e:	0141                	addi	sp,sp,16
    80002620:	8082                	ret

0000000080002622 <usertrapret>:
//
// return to user space
//
void
usertrapret(void)
{
    80002622:	1141                	addi	sp,sp,-16
    80002624:	e406                	sd	ra,8(sp)
    80002626:	e022                	sd	s0,0(sp)
    80002628:	0800                	addi	s0,sp,16
  struct proc *p = myproc();
    8000262a:	fffff097          	auipc	ra,0xfffff
    8000262e:	380080e7          	jalr	896(ra) # 800019aa <myproc>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002632:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    80002636:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002638:	10079073          	csrw	sstatus,a5
  // kerneltrap() to usertrap(), so turn off interrupts until
  // we're back in user space, where usertrap() is correct.
  intr_off();

  // send syscalls, interrupts, and exceptions to trampoline.S
  w_stvec(TRAMPOLINE + (uservec - trampoline));
    8000263c:	00005697          	auipc	a3,0x5
    80002640:	9c468693          	addi	a3,a3,-1596 # 80007000 <_trampoline>
    80002644:	00005717          	auipc	a4,0x5
    80002648:	9bc70713          	addi	a4,a4,-1604 # 80007000 <_trampoline>
    8000264c:	8f15                	sub	a4,a4,a3
    8000264e:	040007b7          	lui	a5,0x4000
    80002652:	17fd                	addi	a5,a5,-1 # 3ffffff <_entry-0x7c000001>
    80002654:	07b2                	slli	a5,a5,0xc
    80002656:	973e                	add	a4,a4,a5
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002658:	10571073          	csrw	stvec,a4

  // set up trapframe values that uservec will need when
  // the process next re-enters the kernel.
  p->trapframe->kernel_satp = r_satp();         // kernel page table
    8000265c:	6d38                	ld	a4,88(a0)
  asm volatile("csrr %0, satp" : "=r" (x) );
    8000265e:	18002673          	csrr	a2,satp
    80002662:	e310                	sd	a2,0(a4)
  p->trapframe->kernel_sp = p->kstack + PGSIZE; // process's kernel stack
    80002664:	6d30                	ld	a2,88(a0)
    80002666:	6138                	ld	a4,64(a0)
    80002668:	6585                	lui	a1,0x1
    8000266a:	972e                	add	a4,a4,a1
    8000266c:	e618                	sd	a4,8(a2)
  p->trapframe->kernel_trap = (uint64)usertrap;
    8000266e:	6d38                	ld	a4,88(a0)
    80002670:	00000617          	auipc	a2,0x0
    80002674:	13860613          	addi	a2,a2,312 # 800027a8 <usertrap>
    80002678:	eb10                	sd	a2,16(a4)
  p->trapframe->kernel_hartid = r_tp();         // hartid for cpuid()
    8000267a:	6d38                	ld	a4,88(a0)
  asm volatile("mv %0, tp" : "=r" (x) );
    8000267c:	8612                	mv	a2,tp
    8000267e:	f310                	sd	a2,32(a4)
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002680:	10002773          	csrr	a4,sstatus
  // set up the registers that trampoline.S's sret will use
  // to get to user space.
  
  // set S Previous Privilege mode to User.
  unsigned long x = r_sstatus();
  x &= ~SSTATUS_SPP; // clear SPP to 0 for user mode
    80002684:	eff77713          	andi	a4,a4,-257
  x |= SSTATUS_SPIE; // enable interrupts in user mode
    80002688:	02076713          	ori	a4,a4,32
  asm volatile("csrw sstatus, %0" : : "r" (x));
    8000268c:	10071073          	csrw	sstatus,a4
  w_sstatus(x);

  // set S Exception Program Counter to the saved user pc.
  w_sepc(p->trapframe->epc);
    80002690:	6d38                	ld	a4,88(a0)
  asm volatile("csrw sepc, %0" : : "r" (x));
    80002692:	6f18                	ld	a4,24(a4)
    80002694:	14171073          	csrw	sepc,a4

  // tell trampoline.S the user page table to switch to.
  uint64 satp = MAKE_SATP(p->pagetable);
    80002698:	692c                	ld	a1,80(a0)
    8000269a:	81b1                	srli	a1,a1,0xc

  // jump to trampoline.S at the top of memory, which 
  // switches to the user page table, restores user registers,
  // and switches to user mode with sret.
  uint64 fn = TRAMPOLINE + (userret - trampoline);
    8000269c:	00005717          	auipc	a4,0x5
    800026a0:	9f470713          	addi	a4,a4,-1548 # 80007090 <userret>
    800026a4:	8f15                	sub	a4,a4,a3
    800026a6:	97ba                	add	a5,a5,a4
  ((void (*)(uint64,uint64))fn)(TRAPFRAME, satp);
    800026a8:	577d                	li	a4,-1
    800026aa:	177e                	slli	a4,a4,0x3f
    800026ac:	8dd9                	or	a1,a1,a4
    800026ae:	02000537          	lui	a0,0x2000
    800026b2:	157d                	addi	a0,a0,-1 # 1ffffff <_entry-0x7e000001>
    800026b4:	0536                	slli	a0,a0,0xd
    800026b6:	9782                	jalr	a5
}
    800026b8:	60a2                	ld	ra,8(sp)
    800026ba:	6402                	ld	s0,0(sp)
    800026bc:	0141                	addi	sp,sp,16
    800026be:	8082                	ret

00000000800026c0 <clockintr>:
  w_sstatus(sstatus);
}

void
clockintr()
{
    800026c0:	1101                	addi	sp,sp,-32
    800026c2:	ec06                	sd	ra,24(sp)
    800026c4:	e822                	sd	s0,16(sp)
    800026c6:	e426                	sd	s1,8(sp)
    800026c8:	1000                	addi	s0,sp,32
  acquire(&tickslock);
    800026ca:	00010497          	auipc	s1,0x10
    800026ce:	dfe48493          	addi	s1,s1,-514 # 800124c8 <tickslock>
    800026d2:	8526                	mv	a0,s1
    800026d4:	ffffe097          	auipc	ra,0xffffe
    800026d8:	4ee080e7          	jalr	1262(ra) # 80000bc2 <acquire>
  ticks++;
    800026dc:	00007517          	auipc	a0,0x7
    800026e0:	95450513          	addi	a0,a0,-1708 # 80009030 <ticks>
    800026e4:	411c                	lw	a5,0(a0)
    800026e6:	2785                	addiw	a5,a5,1
    800026e8:	c11c                	sw	a5,0(a0)
  wakeup(&ticks);
    800026ea:	00000097          	auipc	ra,0x0
    800026ee:	c58080e7          	jalr	-936(ra) # 80002342 <wakeup>
  release(&tickslock);
    800026f2:	8526                	mv	a0,s1
    800026f4:	ffffe097          	auipc	ra,0xffffe
    800026f8:	582080e7          	jalr	1410(ra) # 80000c76 <release>
}
    800026fc:	60e2                	ld	ra,24(sp)
    800026fe:	6442                	ld	s0,16(sp)
    80002700:	64a2                	ld	s1,8(sp)
    80002702:	6105                	addi	sp,sp,32
    80002704:	8082                	ret

0000000080002706 <devintr>:
// returns 2 if timer interrupt,
// 1 if other device,
// 0 if not recognized.
int
devintr()
{
    80002706:	1101                	addi	sp,sp,-32
    80002708:	ec06                	sd	ra,24(sp)
    8000270a:	e822                	sd	s0,16(sp)
    8000270c:	e426                	sd	s1,8(sp)
    8000270e:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002710:	14202773          	csrr	a4,scause
  uint64 scause = r_scause();

  if((scause & 0x8000000000000000L) &&
    80002714:	00074d63          	bltz	a4,8000272e <devintr+0x28>
    // now allowed to interrupt again.
    if(irq)
      plic_complete(irq);

    return 1;
  } else if(scause == 0x8000000000000001L){
    80002718:	57fd                	li	a5,-1
    8000271a:	17fe                	slli	a5,a5,0x3f
    8000271c:	0785                	addi	a5,a5,1
    // the SSIP bit in sip.
    w_sip(r_sip() & ~2);

    return 2;
  } else {
    return 0;
    8000271e:	4501                	li	a0,0
  } else if(scause == 0x8000000000000001L){
    80002720:	06f70363          	beq	a4,a5,80002786 <devintr+0x80>
  }
}
    80002724:	60e2                	ld	ra,24(sp)
    80002726:	6442                	ld	s0,16(sp)
    80002728:	64a2                	ld	s1,8(sp)
    8000272a:	6105                	addi	sp,sp,32
    8000272c:	8082                	ret
     (scause & 0xff) == 9){
    8000272e:	0ff77793          	zext.b	a5,a4
  if((scause & 0x8000000000000000L) &&
    80002732:	46a5                	li	a3,9
    80002734:	fed792e3          	bne	a5,a3,80002718 <devintr+0x12>
    int irq = plic_claim();
    80002738:	00003097          	auipc	ra,0x3
    8000273c:	6e0080e7          	jalr	1760(ra) # 80005e18 <plic_claim>
    80002740:	84aa                	mv	s1,a0
    if(irq == UART0_IRQ){
    80002742:	47a9                	li	a5,10
    80002744:	02f50763          	beq	a0,a5,80002772 <devintr+0x6c>
    } else if(irq == VIRTIO0_IRQ){
    80002748:	4785                	li	a5,1
    8000274a:	02f50963          	beq	a0,a5,8000277c <devintr+0x76>
    return 1;
    8000274e:	4505                	li	a0,1
    } else if(irq){
    80002750:	d8f1                	beqz	s1,80002724 <devintr+0x1e>
      printf("unexpected interrupt irq=%d\n", irq);
    80002752:	85a6                	mv	a1,s1
    80002754:	00006517          	auipc	a0,0x6
    80002758:	b7c50513          	addi	a0,a0,-1156 # 800082d0 <states.0+0x30>
    8000275c:	ffffe097          	auipc	ra,0xffffe
    80002760:	e1a080e7          	jalr	-486(ra) # 80000576 <printf>
      plic_complete(irq);
    80002764:	8526                	mv	a0,s1
    80002766:	00003097          	auipc	ra,0x3
    8000276a:	6d6080e7          	jalr	1750(ra) # 80005e3c <plic_complete>
    return 1;
    8000276e:	4505                	li	a0,1
    80002770:	bf55                	j	80002724 <devintr+0x1e>
      uartintr();
    80002772:	ffffe097          	auipc	ra,0xffffe
    80002776:	212080e7          	jalr	530(ra) # 80000984 <uartintr>
    8000277a:	b7ed                	j	80002764 <devintr+0x5e>
      virtio_disk_intr();
    8000277c:	00004097          	auipc	ra,0x4
    80002780:	b4c080e7          	jalr	-1204(ra) # 800062c8 <virtio_disk_intr>
    80002784:	b7c5                	j	80002764 <devintr+0x5e>
    if(cpuid() == 0){
    80002786:	fffff097          	auipc	ra,0xfffff
    8000278a:	1f8080e7          	jalr	504(ra) # 8000197e <cpuid>
    8000278e:	c901                	beqz	a0,8000279e <devintr+0x98>
  asm volatile("csrr %0, sip" : "=r" (x) );
    80002790:	144027f3          	csrr	a5,sip
    w_sip(r_sip() & ~2);
    80002794:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sip, %0" : : "r" (x));
    80002796:	14479073          	csrw	sip,a5
    return 2;
    8000279a:	4509                	li	a0,2
    8000279c:	b761                	j	80002724 <devintr+0x1e>
      clockintr();
    8000279e:	00000097          	auipc	ra,0x0
    800027a2:	f22080e7          	jalr	-222(ra) # 800026c0 <clockintr>
    800027a6:	b7ed                	j	80002790 <devintr+0x8a>

00000000800027a8 <usertrap>:
{
    800027a8:	1101                	addi	sp,sp,-32
    800027aa:	ec06                	sd	ra,24(sp)
    800027ac:	e822                	sd	s0,16(sp)
    800027ae:	e426                	sd	s1,8(sp)
    800027b0:	e04a                	sd	s2,0(sp)
    800027b2:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800027b4:	100027f3          	csrr	a5,sstatus
  if((r_sstatus() & SSTATUS_SPP) != 0)
    800027b8:	1007f793          	andi	a5,a5,256
    800027bc:	e3ad                	bnez	a5,8000281e <usertrap+0x76>
  asm volatile("csrw stvec, %0" : : "r" (x));
    800027be:	00003797          	auipc	a5,0x3
    800027c2:	55278793          	addi	a5,a5,1362 # 80005d10 <kernelvec>
    800027c6:	10579073          	csrw	stvec,a5
  struct proc *p = myproc();
    800027ca:	fffff097          	auipc	ra,0xfffff
    800027ce:	1e0080e7          	jalr	480(ra) # 800019aa <myproc>
    800027d2:	84aa                	mv	s1,a0
  p->trapframe->epc = r_sepc();
    800027d4:	6d3c                	ld	a5,88(a0)
  asm volatile("csrr %0, sepc" : "=r" (x) );
    800027d6:	14102773          	csrr	a4,sepc
    800027da:	ef98                	sd	a4,24(a5)
  asm volatile("csrr %0, scause" : "=r" (x) );
    800027dc:	14202773          	csrr	a4,scause
  if(r_scause() == 8){
    800027e0:	47a1                	li	a5,8
    800027e2:	04f71c63          	bne	a4,a5,8000283a <usertrap+0x92>
    if(p->killed)
    800027e6:	591c                	lw	a5,48(a0)
    800027e8:	e3b9                	bnez	a5,8000282e <usertrap+0x86>
    p->trapframe->epc += 4;
    800027ea:	6cb8                	ld	a4,88(s1)
    800027ec:	6f1c                	ld	a5,24(a4)
    800027ee:	0791                	addi	a5,a5,4
    800027f0:	ef1c                	sd	a5,24(a4)
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800027f2:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    800027f6:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    800027fa:	10079073          	csrw	sstatus,a5
    syscall();
    800027fe:	00000097          	auipc	ra,0x0
    80002802:	2e0080e7          	jalr	736(ra) # 80002ade <syscall>
  if(p->killed)
    80002806:	589c                	lw	a5,48(s1)
    80002808:	ebc1                	bnez	a5,80002898 <usertrap+0xf0>
  usertrapret();
    8000280a:	00000097          	auipc	ra,0x0
    8000280e:	e18080e7          	jalr	-488(ra) # 80002622 <usertrapret>
}
    80002812:	60e2                	ld	ra,24(sp)
    80002814:	6442                	ld	s0,16(sp)
    80002816:	64a2                	ld	s1,8(sp)
    80002818:	6902                	ld	s2,0(sp)
    8000281a:	6105                	addi	sp,sp,32
    8000281c:	8082                	ret
    panic("usertrap: not from user mode");
    8000281e:	00006517          	auipc	a0,0x6
    80002822:	ad250513          	addi	a0,a0,-1326 # 800082f0 <states.0+0x50>
    80002826:	ffffe097          	auipc	ra,0xffffe
    8000282a:	d06080e7          	jalr	-762(ra) # 8000052c <panic>
      exit(-1);
    8000282e:	557d                	li	a0,-1
    80002830:	00000097          	auipc	ra,0x0
    80002834:	84c080e7          	jalr	-1972(ra) # 8000207c <exit>
    80002838:	bf4d                	j	800027ea <usertrap+0x42>
  } else if((which_dev = devintr()) != 0){
    8000283a:	00000097          	auipc	ra,0x0
    8000283e:	ecc080e7          	jalr	-308(ra) # 80002706 <devintr>
    80002842:	892a                	mv	s2,a0
    80002844:	c501                	beqz	a0,8000284c <usertrap+0xa4>
  if(p->killed)
    80002846:	589c                	lw	a5,48(s1)
    80002848:	c3a1                	beqz	a5,80002888 <usertrap+0xe0>
    8000284a:	a815                	j	8000287e <usertrap+0xd6>
  asm volatile("csrr %0, scause" : "=r" (x) );
    8000284c:	142025f3          	csrr	a1,scause
    printf("usertrap(): unexpected scause %p pid=%d\n", r_scause(), p->pid);
    80002850:	5c90                	lw	a2,56(s1)
    80002852:	00006517          	auipc	a0,0x6
    80002856:	abe50513          	addi	a0,a0,-1346 # 80008310 <states.0+0x70>
    8000285a:	ffffe097          	auipc	ra,0xffffe
    8000285e:	d1c080e7          	jalr	-740(ra) # 80000576 <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    80002862:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    80002866:	14302673          	csrr	a2,stval
    printf("            sepc=%p stval=%p\n", r_sepc(), r_stval());
    8000286a:	00006517          	auipc	a0,0x6
    8000286e:	ad650513          	addi	a0,a0,-1322 # 80008340 <states.0+0xa0>
    80002872:	ffffe097          	auipc	ra,0xffffe
    80002876:	d04080e7          	jalr	-764(ra) # 80000576 <printf>
    p->killed = 1;
    8000287a:	4785                	li	a5,1
    8000287c:	d89c                	sw	a5,48(s1)
    exit(-1);
    8000287e:	557d                	li	a0,-1
    80002880:	fffff097          	auipc	ra,0xfffff
    80002884:	7fc080e7          	jalr	2044(ra) # 8000207c <exit>
  if(which_dev == 2)
    80002888:	4789                	li	a5,2
    8000288a:	f8f910e3          	bne	s2,a5,8000280a <usertrap+0x62>
    yield();
    8000288e:	00000097          	auipc	ra,0x0
    80002892:	8f8080e7          	jalr	-1800(ra) # 80002186 <yield>
    80002896:	bf95                	j	8000280a <usertrap+0x62>
  int which_dev = 0;
    80002898:	4901                	li	s2,0
    8000289a:	b7d5                	j	8000287e <usertrap+0xd6>

000000008000289c <kerneltrap>:
{
    8000289c:	7179                	addi	sp,sp,-48
    8000289e:	f406                	sd	ra,40(sp)
    800028a0:	f022                	sd	s0,32(sp)
    800028a2:	ec26                	sd	s1,24(sp)
    800028a4:	e84a                	sd	s2,16(sp)
    800028a6:	e44e                	sd	s3,8(sp)
    800028a8:	1800                	addi	s0,sp,48
  asm volatile("csrr %0, sepc" : "=r" (x) );
    800028aa:	14102973          	csrr	s2,sepc
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800028ae:	100024f3          	csrr	s1,sstatus
  asm volatile("csrr %0, scause" : "=r" (x) );
    800028b2:	142029f3          	csrr	s3,scause
  if((sstatus & SSTATUS_SPP) == 0)
    800028b6:	1004f793          	andi	a5,s1,256
    800028ba:	cb85                	beqz	a5,800028ea <kerneltrap+0x4e>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800028bc:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    800028c0:	8b89                	andi	a5,a5,2
  if(intr_get() != 0)
    800028c2:	ef85                	bnez	a5,800028fa <kerneltrap+0x5e>
  if((which_dev = devintr()) == 0){
    800028c4:	00000097          	auipc	ra,0x0
    800028c8:	e42080e7          	jalr	-446(ra) # 80002706 <devintr>
    800028cc:	cd1d                	beqz	a0,8000290a <kerneltrap+0x6e>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    800028ce:	4789                	li	a5,2
    800028d0:	06f50a63          	beq	a0,a5,80002944 <kerneltrap+0xa8>
  asm volatile("csrw sepc, %0" : : "r" (x));
    800028d4:	14191073          	csrw	sepc,s2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    800028d8:	10049073          	csrw	sstatus,s1
}
    800028dc:	70a2                	ld	ra,40(sp)
    800028de:	7402                	ld	s0,32(sp)
    800028e0:	64e2                	ld	s1,24(sp)
    800028e2:	6942                	ld	s2,16(sp)
    800028e4:	69a2                	ld	s3,8(sp)
    800028e6:	6145                	addi	sp,sp,48
    800028e8:	8082                	ret
    panic("kerneltrap: not from supervisor mode");
    800028ea:	00006517          	auipc	a0,0x6
    800028ee:	a7650513          	addi	a0,a0,-1418 # 80008360 <states.0+0xc0>
    800028f2:	ffffe097          	auipc	ra,0xffffe
    800028f6:	c3a080e7          	jalr	-966(ra) # 8000052c <panic>
    panic("kerneltrap: interrupts enabled");
    800028fa:	00006517          	auipc	a0,0x6
    800028fe:	a8e50513          	addi	a0,a0,-1394 # 80008388 <states.0+0xe8>
    80002902:	ffffe097          	auipc	ra,0xffffe
    80002906:	c2a080e7          	jalr	-982(ra) # 8000052c <panic>
    printf("scause %p\n", scause);
    8000290a:	85ce                	mv	a1,s3
    8000290c:	00006517          	auipc	a0,0x6
    80002910:	a9c50513          	addi	a0,a0,-1380 # 800083a8 <states.0+0x108>
    80002914:	ffffe097          	auipc	ra,0xffffe
    80002918:	c62080e7          	jalr	-926(ra) # 80000576 <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    8000291c:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    80002920:	14302673          	csrr	a2,stval
    printf("sepc=%p stval=%p\n", r_sepc(), r_stval());
    80002924:	00006517          	auipc	a0,0x6
    80002928:	a9450513          	addi	a0,a0,-1388 # 800083b8 <states.0+0x118>
    8000292c:	ffffe097          	auipc	ra,0xffffe
    80002930:	c4a080e7          	jalr	-950(ra) # 80000576 <printf>
    panic("kerneltrap");
    80002934:	00006517          	auipc	a0,0x6
    80002938:	a9c50513          	addi	a0,a0,-1380 # 800083d0 <states.0+0x130>
    8000293c:	ffffe097          	auipc	ra,0xffffe
    80002940:	bf0080e7          	jalr	-1040(ra) # 8000052c <panic>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    80002944:	fffff097          	auipc	ra,0xfffff
    80002948:	066080e7          	jalr	102(ra) # 800019aa <myproc>
    8000294c:	d541                	beqz	a0,800028d4 <kerneltrap+0x38>
    8000294e:	fffff097          	auipc	ra,0xfffff
    80002952:	05c080e7          	jalr	92(ra) # 800019aa <myproc>
    80002956:	4d18                	lw	a4,24(a0)
    80002958:	478d                	li	a5,3
    8000295a:	f6f71de3          	bne	a4,a5,800028d4 <kerneltrap+0x38>
    yield();
    8000295e:	00000097          	auipc	ra,0x0
    80002962:	828080e7          	jalr	-2008(ra) # 80002186 <yield>
    80002966:	b7bd                	j	800028d4 <kerneltrap+0x38>

0000000080002968 <argraw>:
  return strlen(buf);
}

static uint64
argraw(int n)
{
    80002968:	1101                	addi	sp,sp,-32
    8000296a:	ec06                	sd	ra,24(sp)
    8000296c:	e822                	sd	s0,16(sp)
    8000296e:	e426                	sd	s1,8(sp)
    80002970:	1000                	addi	s0,sp,32
    80002972:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80002974:	fffff097          	auipc	ra,0xfffff
    80002978:	036080e7          	jalr	54(ra) # 800019aa <myproc>
  switch (n) {
    8000297c:	4795                	li	a5,5
    8000297e:	0497e163          	bltu	a5,s1,800029c0 <argraw+0x58>
    80002982:	048a                	slli	s1,s1,0x2
    80002984:	00006717          	auipc	a4,0x6
    80002988:	a8470713          	addi	a4,a4,-1404 # 80008408 <states.0+0x168>
    8000298c:	94ba                	add	s1,s1,a4
    8000298e:	409c                	lw	a5,0(s1)
    80002990:	97ba                	add	a5,a5,a4
    80002992:	8782                	jr	a5
  case 0:
    return p->trapframe->a0;
    80002994:	6d3c                	ld	a5,88(a0)
    80002996:	7ba8                	ld	a0,112(a5)
  case 5:
    return p->trapframe->a5;
  }
  panic("argraw");
  return -1;
}
    80002998:	60e2                	ld	ra,24(sp)
    8000299a:	6442                	ld	s0,16(sp)
    8000299c:	64a2                	ld	s1,8(sp)
    8000299e:	6105                	addi	sp,sp,32
    800029a0:	8082                	ret
    return p->trapframe->a1;
    800029a2:	6d3c                	ld	a5,88(a0)
    800029a4:	7fa8                	ld	a0,120(a5)
    800029a6:	bfcd                	j	80002998 <argraw+0x30>
    return p->trapframe->a2;
    800029a8:	6d3c                	ld	a5,88(a0)
    800029aa:	63c8                	ld	a0,128(a5)
    800029ac:	b7f5                	j	80002998 <argraw+0x30>
    return p->trapframe->a3;
    800029ae:	6d3c                	ld	a5,88(a0)
    800029b0:	67c8                	ld	a0,136(a5)
    800029b2:	b7dd                	j	80002998 <argraw+0x30>
    return p->trapframe->a4;
    800029b4:	6d3c                	ld	a5,88(a0)
    800029b6:	6bc8                	ld	a0,144(a5)
    800029b8:	b7c5                	j	80002998 <argraw+0x30>
    return p->trapframe->a5;
    800029ba:	6d3c                	ld	a5,88(a0)
    800029bc:	6fc8                	ld	a0,152(a5)
    800029be:	bfe9                	j	80002998 <argraw+0x30>
  panic("argraw");
    800029c0:	00006517          	auipc	a0,0x6
    800029c4:	a2050513          	addi	a0,a0,-1504 # 800083e0 <states.0+0x140>
    800029c8:	ffffe097          	auipc	ra,0xffffe
    800029cc:	b64080e7          	jalr	-1180(ra) # 8000052c <panic>

00000000800029d0 <fetchaddr>:
{
    800029d0:	1101                	addi	sp,sp,-32
    800029d2:	ec06                	sd	ra,24(sp)
    800029d4:	e822                	sd	s0,16(sp)
    800029d6:	e426                	sd	s1,8(sp)
    800029d8:	e04a                	sd	s2,0(sp)
    800029da:	1000                	addi	s0,sp,32
    800029dc:	84aa                	mv	s1,a0
    800029de:	892e                	mv	s2,a1
  struct proc *p = myproc();
    800029e0:	fffff097          	auipc	ra,0xfffff
    800029e4:	fca080e7          	jalr	-54(ra) # 800019aa <myproc>
  if(addr >= p->sz || addr+sizeof(uint64) > p->sz)
    800029e8:	653c                	ld	a5,72(a0)
    800029ea:	02f4f863          	bgeu	s1,a5,80002a1a <fetchaddr+0x4a>
    800029ee:	00848713          	addi	a4,s1,8
    800029f2:	02e7e663          	bltu	a5,a4,80002a1e <fetchaddr+0x4e>
  if(copyin(p->pagetable, (char *)ip, addr, sizeof(*ip)) != 0)
    800029f6:	46a1                	li	a3,8
    800029f8:	8626                	mv	a2,s1
    800029fa:	85ca                	mv	a1,s2
    800029fc:	6928                	ld	a0,80(a0)
    800029fe:	fffff097          	auipc	ra,0xfffff
    80002a02:	cd0080e7          	jalr	-816(ra) # 800016ce <copyin>
    80002a06:	00a03533          	snez	a0,a0
    80002a0a:	40a00533          	neg	a0,a0
}
    80002a0e:	60e2                	ld	ra,24(sp)
    80002a10:	6442                	ld	s0,16(sp)
    80002a12:	64a2                	ld	s1,8(sp)
    80002a14:	6902                	ld	s2,0(sp)
    80002a16:	6105                	addi	sp,sp,32
    80002a18:	8082                	ret
    return -1;
    80002a1a:	557d                	li	a0,-1
    80002a1c:	bfcd                	j	80002a0e <fetchaddr+0x3e>
    80002a1e:	557d                	li	a0,-1
    80002a20:	b7fd                	j	80002a0e <fetchaddr+0x3e>

0000000080002a22 <fetchstr>:
{
    80002a22:	7179                	addi	sp,sp,-48
    80002a24:	f406                	sd	ra,40(sp)
    80002a26:	f022                	sd	s0,32(sp)
    80002a28:	ec26                	sd	s1,24(sp)
    80002a2a:	e84a                	sd	s2,16(sp)
    80002a2c:	e44e                	sd	s3,8(sp)
    80002a2e:	1800                	addi	s0,sp,48
    80002a30:	892a                	mv	s2,a0
    80002a32:	84ae                	mv	s1,a1
    80002a34:	89b2                	mv	s3,a2
  struct proc *p = myproc();
    80002a36:	fffff097          	auipc	ra,0xfffff
    80002a3a:	f74080e7          	jalr	-140(ra) # 800019aa <myproc>
  int err = copyinstr(p->pagetable, buf, addr, max);
    80002a3e:	86ce                	mv	a3,s3
    80002a40:	864a                	mv	a2,s2
    80002a42:	85a6                	mv	a1,s1
    80002a44:	6928                	ld	a0,80(a0)
    80002a46:	fffff097          	auipc	ra,0xfffff
    80002a4a:	d16080e7          	jalr	-746(ra) # 8000175c <copyinstr>
  if(err < 0)
    80002a4e:	00054763          	bltz	a0,80002a5c <fetchstr+0x3a>
  return strlen(buf);
    80002a52:	8526                	mv	a0,s1
    80002a54:	ffffe097          	auipc	ra,0xffffe
    80002a58:	3ee080e7          	jalr	1006(ra) # 80000e42 <strlen>
}
    80002a5c:	70a2                	ld	ra,40(sp)
    80002a5e:	7402                	ld	s0,32(sp)
    80002a60:	64e2                	ld	s1,24(sp)
    80002a62:	6942                	ld	s2,16(sp)
    80002a64:	69a2                	ld	s3,8(sp)
    80002a66:	6145                	addi	sp,sp,48
    80002a68:	8082                	ret

0000000080002a6a <argint>:

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
    80002a6a:	1101                	addi	sp,sp,-32
    80002a6c:	ec06                	sd	ra,24(sp)
    80002a6e:	e822                	sd	s0,16(sp)
    80002a70:	e426                	sd	s1,8(sp)
    80002a72:	1000                	addi	s0,sp,32
    80002a74:	84ae                	mv	s1,a1
  *ip = argraw(n);
    80002a76:	00000097          	auipc	ra,0x0
    80002a7a:	ef2080e7          	jalr	-270(ra) # 80002968 <argraw>
    80002a7e:	c088                	sw	a0,0(s1)
  return 0;
}
    80002a80:	4501                	li	a0,0
    80002a82:	60e2                	ld	ra,24(sp)
    80002a84:	6442                	ld	s0,16(sp)
    80002a86:	64a2                	ld	s1,8(sp)
    80002a88:	6105                	addi	sp,sp,32
    80002a8a:	8082                	ret

0000000080002a8c <argaddr>:
// Retrieve an argument as a pointer.
// Doesn't check for legality, since
// copyin/copyout will do that.
int
argaddr(int n, uint64 *ip)
{
    80002a8c:	1101                	addi	sp,sp,-32
    80002a8e:	ec06                	sd	ra,24(sp)
    80002a90:	e822                	sd	s0,16(sp)
    80002a92:	e426                	sd	s1,8(sp)
    80002a94:	1000                	addi	s0,sp,32
    80002a96:	84ae                	mv	s1,a1
  *ip = argraw(n);
    80002a98:	00000097          	auipc	ra,0x0
    80002a9c:	ed0080e7          	jalr	-304(ra) # 80002968 <argraw>
    80002aa0:	e088                	sd	a0,0(s1)
  return 0;
}
    80002aa2:	4501                	li	a0,0
    80002aa4:	60e2                	ld	ra,24(sp)
    80002aa6:	6442                	ld	s0,16(sp)
    80002aa8:	64a2                	ld	s1,8(sp)
    80002aaa:	6105                	addi	sp,sp,32
    80002aac:	8082                	ret

0000000080002aae <argstr>:
// Fetch the nth word-sized system call argument as a null-terminated string.
// Copies into buf, at most max.
// Returns string length if OK (including nul), -1 if error.
int
argstr(int n, char *buf, int max)
{
    80002aae:	1101                	addi	sp,sp,-32
    80002ab0:	ec06                	sd	ra,24(sp)
    80002ab2:	e822                	sd	s0,16(sp)
    80002ab4:	e426                	sd	s1,8(sp)
    80002ab6:	e04a                	sd	s2,0(sp)
    80002ab8:	1000                	addi	s0,sp,32
    80002aba:	84ae                	mv	s1,a1
    80002abc:	8932                	mv	s2,a2
  *ip = argraw(n);
    80002abe:	00000097          	auipc	ra,0x0
    80002ac2:	eaa080e7          	jalr	-342(ra) # 80002968 <argraw>
  uint64 addr;
  if(argaddr(n, &addr) < 0)
    return -1;
  return fetchstr(addr, buf, max);
    80002ac6:	864a                	mv	a2,s2
    80002ac8:	85a6                	mv	a1,s1
    80002aca:	00000097          	auipc	ra,0x0
    80002ace:	f58080e7          	jalr	-168(ra) # 80002a22 <fetchstr>
}
    80002ad2:	60e2                	ld	ra,24(sp)
    80002ad4:	6442                	ld	s0,16(sp)
    80002ad6:	64a2                	ld	s1,8(sp)
    80002ad8:	6902                	ld	s2,0(sp)
    80002ada:	6105                	addi	sp,sp,32
    80002adc:	8082                	ret

0000000080002ade <syscall>:
[SYS_rbtn]    sys_rbtn,
};

void
syscall(void)
{
    80002ade:	1101                	addi	sp,sp,-32
    80002ae0:	ec06                	sd	ra,24(sp)
    80002ae2:	e822                	sd	s0,16(sp)
    80002ae4:	e426                	sd	s1,8(sp)
    80002ae6:	e04a                	sd	s2,0(sp)
    80002ae8:	1000                	addi	s0,sp,32
  int num;
  struct proc *p = myproc();
    80002aea:	fffff097          	auipc	ra,0xfffff
    80002aee:	ec0080e7          	jalr	-320(ra) # 800019aa <myproc>
    80002af2:	84aa                	mv	s1,a0

  num = p->trapframe->a7;
    80002af4:	05853903          	ld	s2,88(a0)
    80002af8:	0a893783          	ld	a5,168(s2)
    80002afc:	0007869b          	sext.w	a3,a5
  if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
    80002b00:	37fd                	addiw	a5,a5,-1
    80002b02:	4755                	li	a4,21
    80002b04:	00f76f63          	bltu	a4,a5,80002b22 <syscall+0x44>
    80002b08:	00369713          	slli	a4,a3,0x3
    80002b0c:	00006797          	auipc	a5,0x6
    80002b10:	91478793          	addi	a5,a5,-1772 # 80008420 <syscalls>
    80002b14:	97ba                	add	a5,a5,a4
    80002b16:	639c                	ld	a5,0(a5)
    80002b18:	c789                	beqz	a5,80002b22 <syscall+0x44>
    p->trapframe->a0 = syscalls[num]();
    80002b1a:	9782                	jalr	a5
    80002b1c:	06a93823          	sd	a0,112(s2)
    80002b20:	a839                	j	80002b3e <syscall+0x60>
  } else {
    printf("%d %s: unknown sys call %d\n",
    80002b22:	15848613          	addi	a2,s1,344
    80002b26:	5c8c                	lw	a1,56(s1)
    80002b28:	00006517          	auipc	a0,0x6
    80002b2c:	8c050513          	addi	a0,a0,-1856 # 800083e8 <states.0+0x148>
    80002b30:	ffffe097          	auipc	ra,0xffffe
    80002b34:	a46080e7          	jalr	-1466(ra) # 80000576 <printf>
            p->pid, p->name, num);
    p->trapframe->a0 = -1;
    80002b38:	6cbc                	ld	a5,88(s1)
    80002b3a:	577d                	li	a4,-1
    80002b3c:	fbb8                	sd	a4,112(a5)
  }
}
    80002b3e:	60e2                	ld	ra,24(sp)
    80002b40:	6442                	ld	s0,16(sp)
    80002b42:	64a2                	ld	s1,8(sp)
    80002b44:	6902                	ld	s2,0(sp)
    80002b46:	6105                	addi	sp,sp,32
    80002b48:	8082                	ret

0000000080002b4a <sys_exit>:
#include "spinlock.h"
#include "proc.h"

uint64
sys_exit(void)
{
    80002b4a:	1101                	addi	sp,sp,-32
    80002b4c:	ec06                	sd	ra,24(sp)
    80002b4e:	e822                	sd	s0,16(sp)
    80002b50:	1000                	addi	s0,sp,32
  int n;
  if(argint(0, &n) < 0)
    80002b52:	fec40593          	addi	a1,s0,-20
    80002b56:	4501                	li	a0,0
    80002b58:	00000097          	auipc	ra,0x0
    80002b5c:	f12080e7          	jalr	-238(ra) # 80002a6a <argint>
    return -1;
    80002b60:	57fd                	li	a5,-1
  if(argint(0, &n) < 0)
    80002b62:	00054963          	bltz	a0,80002b74 <sys_exit+0x2a>
  exit(n);
    80002b66:	fec42503          	lw	a0,-20(s0)
    80002b6a:	fffff097          	auipc	ra,0xfffff
    80002b6e:	512080e7          	jalr	1298(ra) # 8000207c <exit>
  return 0;  // not reached
    80002b72:	4781                	li	a5,0
}
    80002b74:	853e                	mv	a0,a5
    80002b76:	60e2                	ld	ra,24(sp)
    80002b78:	6442                	ld	s0,16(sp)
    80002b7a:	6105                	addi	sp,sp,32
    80002b7c:	8082                	ret

0000000080002b7e <sys_getpid>:

uint64
sys_getpid(void)
{
    80002b7e:	1141                	addi	sp,sp,-16
    80002b80:	e406                	sd	ra,8(sp)
    80002b82:	e022                	sd	s0,0(sp)
    80002b84:	0800                	addi	s0,sp,16
  return myproc()->pid;
    80002b86:	fffff097          	auipc	ra,0xfffff
    80002b8a:	e24080e7          	jalr	-476(ra) # 800019aa <myproc>
}
    80002b8e:	5d08                	lw	a0,56(a0)
    80002b90:	60a2                	ld	ra,8(sp)
    80002b92:	6402                	ld	s0,0(sp)
    80002b94:	0141                	addi	sp,sp,16
    80002b96:	8082                	ret

0000000080002b98 <sys_fork>:

uint64
sys_fork(void)
{
    80002b98:	1141                	addi	sp,sp,-16
    80002b9a:	e406                	sd	ra,8(sp)
    80002b9c:	e022                	sd	s0,0(sp)
    80002b9e:	0800                	addi	s0,sp,16
  return fork();
    80002ba0:	fffff097          	auipc	ra,0xfffff
    80002ba4:	1ce080e7          	jalr	462(ra) # 80001d6e <fork>
}
    80002ba8:	60a2                	ld	ra,8(sp)
    80002baa:	6402                	ld	s0,0(sp)
    80002bac:	0141                	addi	sp,sp,16
    80002bae:	8082                	ret

0000000080002bb0 <sys_wait>:

uint64
sys_wait(void)
{
    80002bb0:	1101                	addi	sp,sp,-32
    80002bb2:	ec06                	sd	ra,24(sp)
    80002bb4:	e822                	sd	s0,16(sp)
    80002bb6:	1000                	addi	s0,sp,32
  uint64 p;
  if(argaddr(0, &p) < 0)
    80002bb8:	fe840593          	addi	a1,s0,-24
    80002bbc:	4501                	li	a0,0
    80002bbe:	00000097          	auipc	ra,0x0
    80002bc2:	ece080e7          	jalr	-306(ra) # 80002a8c <argaddr>
    80002bc6:	87aa                	mv	a5,a0
    return -1;
    80002bc8:	557d                	li	a0,-1
  if(argaddr(0, &p) < 0)
    80002bca:	0007c863          	bltz	a5,80002bda <sys_wait+0x2a>
  return wait(p);
    80002bce:	fe843503          	ld	a0,-24(s0)
    80002bd2:	fffff097          	auipc	ra,0xfffff
    80002bd6:	66e080e7          	jalr	1646(ra) # 80002240 <wait>
}
    80002bda:	60e2                	ld	ra,24(sp)
    80002bdc:	6442                	ld	s0,16(sp)
    80002bde:	6105                	addi	sp,sp,32
    80002be0:	8082                	ret

0000000080002be2 <sys_sbrk>:

uint64
sys_sbrk(void)
{
    80002be2:	7179                	addi	sp,sp,-48
    80002be4:	f406                	sd	ra,40(sp)
    80002be6:	f022                	sd	s0,32(sp)
    80002be8:	ec26                	sd	s1,24(sp)
    80002bea:	1800                	addi	s0,sp,48
  int addr;
  int n;

  if(argint(0, &n) < 0)
    80002bec:	fdc40593          	addi	a1,s0,-36
    80002bf0:	4501                	li	a0,0
    80002bf2:	00000097          	auipc	ra,0x0
    80002bf6:	e78080e7          	jalr	-392(ra) # 80002a6a <argint>
    80002bfa:	87aa                	mv	a5,a0
    return -1;
    80002bfc:	557d                	li	a0,-1
  if(argint(0, &n) < 0)
    80002bfe:	0207c063          	bltz	a5,80002c1e <sys_sbrk+0x3c>
  addr = myproc()->sz;
    80002c02:	fffff097          	auipc	ra,0xfffff
    80002c06:	da8080e7          	jalr	-600(ra) # 800019aa <myproc>
    80002c0a:	4524                	lw	s1,72(a0)
  if(growproc(n) < 0)
    80002c0c:	fdc42503          	lw	a0,-36(s0)
    80002c10:	fffff097          	auipc	ra,0xfffff
    80002c14:	0e6080e7          	jalr	230(ra) # 80001cf6 <growproc>
    80002c18:	00054863          	bltz	a0,80002c28 <sys_sbrk+0x46>
    return -1;
  return addr;
    80002c1c:	8526                	mv	a0,s1
}
    80002c1e:	70a2                	ld	ra,40(sp)
    80002c20:	7402                	ld	s0,32(sp)
    80002c22:	64e2                	ld	s1,24(sp)
    80002c24:	6145                	addi	sp,sp,48
    80002c26:	8082                	ret
    return -1;
    80002c28:	557d                	li	a0,-1
    80002c2a:	bfd5                	j	80002c1e <sys_sbrk+0x3c>

0000000080002c2c <sys_sleep>:

uint64
sys_sleep(void)
{
    80002c2c:	7139                	addi	sp,sp,-64
    80002c2e:	fc06                	sd	ra,56(sp)
    80002c30:	f822                	sd	s0,48(sp)
    80002c32:	f426                	sd	s1,40(sp)
    80002c34:	f04a                	sd	s2,32(sp)
    80002c36:	ec4e                	sd	s3,24(sp)
    80002c38:	0080                	addi	s0,sp,64
  int n;
  uint ticks0;

  if(argint(0, &n) < 0)
    80002c3a:	fcc40593          	addi	a1,s0,-52
    80002c3e:	4501                	li	a0,0
    80002c40:	00000097          	auipc	ra,0x0
    80002c44:	e2a080e7          	jalr	-470(ra) # 80002a6a <argint>
    return -1;
    80002c48:	57fd                	li	a5,-1
  if(argint(0, &n) < 0)
    80002c4a:	06054563          	bltz	a0,80002cb4 <sys_sleep+0x88>
  acquire(&tickslock);
    80002c4e:	00010517          	auipc	a0,0x10
    80002c52:	87a50513          	addi	a0,a0,-1926 # 800124c8 <tickslock>
    80002c56:	ffffe097          	auipc	ra,0xffffe
    80002c5a:	f6c080e7          	jalr	-148(ra) # 80000bc2 <acquire>
  ticks0 = ticks;
    80002c5e:	00006917          	auipc	s2,0x6
    80002c62:	3d292903          	lw	s2,978(s2) # 80009030 <ticks>
  while(ticks - ticks0 < n){
    80002c66:	fcc42783          	lw	a5,-52(s0)
    80002c6a:	cf85                	beqz	a5,80002ca2 <sys_sleep+0x76>
    if(myproc()->killed){
      release(&tickslock);
      return -1;
    }
    sleep(&ticks, &tickslock);
    80002c6c:	00010997          	auipc	s3,0x10
    80002c70:	85c98993          	addi	s3,s3,-1956 # 800124c8 <tickslock>
    80002c74:	00006497          	auipc	s1,0x6
    80002c78:	3bc48493          	addi	s1,s1,956 # 80009030 <ticks>
    if(myproc()->killed){
    80002c7c:	fffff097          	auipc	ra,0xfffff
    80002c80:	d2e080e7          	jalr	-722(ra) # 800019aa <myproc>
    80002c84:	591c                	lw	a5,48(a0)
    80002c86:	ef9d                	bnez	a5,80002cc4 <sys_sleep+0x98>
    sleep(&ticks, &tickslock);
    80002c88:	85ce                	mv	a1,s3
    80002c8a:	8526                	mv	a0,s1
    80002c8c:	fffff097          	auipc	ra,0xfffff
    80002c90:	536080e7          	jalr	1334(ra) # 800021c2 <sleep>
  while(ticks - ticks0 < n){
    80002c94:	409c                	lw	a5,0(s1)
    80002c96:	412787bb          	subw	a5,a5,s2
    80002c9a:	fcc42703          	lw	a4,-52(s0)
    80002c9e:	fce7efe3          	bltu	a5,a4,80002c7c <sys_sleep+0x50>
  }
  release(&tickslock);
    80002ca2:	00010517          	auipc	a0,0x10
    80002ca6:	82650513          	addi	a0,a0,-2010 # 800124c8 <tickslock>
    80002caa:	ffffe097          	auipc	ra,0xffffe
    80002cae:	fcc080e7          	jalr	-52(ra) # 80000c76 <release>
  return 0;
    80002cb2:	4781                	li	a5,0
}
    80002cb4:	853e                	mv	a0,a5
    80002cb6:	70e2                	ld	ra,56(sp)
    80002cb8:	7442                	ld	s0,48(sp)
    80002cba:	74a2                	ld	s1,40(sp)
    80002cbc:	7902                	ld	s2,32(sp)
    80002cbe:	69e2                	ld	s3,24(sp)
    80002cc0:	6121                	addi	sp,sp,64
    80002cc2:	8082                	ret
      release(&tickslock);
    80002cc4:	00010517          	auipc	a0,0x10
    80002cc8:	80450513          	addi	a0,a0,-2044 # 800124c8 <tickslock>
    80002ccc:	ffffe097          	auipc	ra,0xffffe
    80002cd0:	faa080e7          	jalr	-86(ra) # 80000c76 <release>
      return -1;
    80002cd4:	57fd                	li	a5,-1
    80002cd6:	bff9                	j	80002cb4 <sys_sleep+0x88>

0000000080002cd8 <sys_kill>:

uint64
sys_kill(void)
{
    80002cd8:	1101                	addi	sp,sp,-32
    80002cda:	ec06                	sd	ra,24(sp)
    80002cdc:	e822                	sd	s0,16(sp)
    80002cde:	1000                	addi	s0,sp,32
  int pid;

  if(argint(0, &pid) < 0)
    80002ce0:	fec40593          	addi	a1,s0,-20
    80002ce4:	4501                	li	a0,0
    80002ce6:	00000097          	auipc	ra,0x0
    80002cea:	d84080e7          	jalr	-636(ra) # 80002a6a <argint>
    80002cee:	87aa                	mv	a5,a0
    return -1;
    80002cf0:	557d                	li	a0,-1
  if(argint(0, &pid) < 0)
    80002cf2:	0007c863          	bltz	a5,80002d02 <sys_kill+0x2a>
  return kill(pid);
    80002cf6:	fec42503          	lw	a0,-20(s0)
    80002cfa:	fffff097          	auipc	ra,0xfffff
    80002cfe:	6b2080e7          	jalr	1714(ra) # 800023ac <kill>
}
    80002d02:	60e2                	ld	ra,24(sp)
    80002d04:	6442                	ld	s0,16(sp)
    80002d06:	6105                	addi	sp,sp,32
    80002d08:	8082                	ret

0000000080002d0a <sys_uptime>:

// return how many clock tick interrupts have occurred
// since start.
uint64
sys_uptime(void)
{
    80002d0a:	1101                	addi	sp,sp,-32
    80002d0c:	ec06                	sd	ra,24(sp)
    80002d0e:	e822                	sd	s0,16(sp)
    80002d10:	e426                	sd	s1,8(sp)
    80002d12:	1000                	addi	s0,sp,32
  uint xticks;

  acquire(&tickslock);
    80002d14:	0000f517          	auipc	a0,0xf
    80002d18:	7b450513          	addi	a0,a0,1972 # 800124c8 <tickslock>
    80002d1c:	ffffe097          	auipc	ra,0xffffe
    80002d20:	ea6080e7          	jalr	-346(ra) # 80000bc2 <acquire>
  xticks = ticks;
    80002d24:	00006497          	auipc	s1,0x6
    80002d28:	30c4a483          	lw	s1,780(s1) # 80009030 <ticks>
  release(&tickslock);
    80002d2c:	0000f517          	auipc	a0,0xf
    80002d30:	79c50513          	addi	a0,a0,1948 # 800124c8 <tickslock>
    80002d34:	ffffe097          	auipc	ra,0xffffe
    80002d38:	f42080e7          	jalr	-190(ra) # 80000c76 <release>
  return xticks;
}
    80002d3c:	02049513          	slli	a0,s1,0x20
    80002d40:	9101                	srli	a0,a0,0x20
    80002d42:	60e2                	ld	ra,24(sp)
    80002d44:	6442                	ld	s0,16(sp)
    80002d46:	64a2                	ld	s1,8(sp)
    80002d48:	6105                	addi	sp,sp,32
    80002d4a:	8082                	ret

0000000080002d4c <binit>:
  struct buf head;
} bcache;

void
binit(void)
{
    80002d4c:	7179                	addi	sp,sp,-48
    80002d4e:	f406                	sd	ra,40(sp)
    80002d50:	f022                	sd	s0,32(sp)
    80002d52:	ec26                	sd	s1,24(sp)
    80002d54:	e84a                	sd	s2,16(sp)
    80002d56:	e44e                	sd	s3,8(sp)
    80002d58:	e052                	sd	s4,0(sp)
    80002d5a:	1800                	addi	s0,sp,48
  struct buf *b;

  initlock(&bcache.lock, "bcache");
    80002d5c:	00005597          	auipc	a1,0x5
    80002d60:	77c58593          	addi	a1,a1,1916 # 800084d8 <syscalls+0xb8>
    80002d64:	0000f517          	auipc	a0,0xf
    80002d68:	77c50513          	addi	a0,a0,1916 # 800124e0 <bcache>
    80002d6c:	ffffe097          	auipc	ra,0xffffe
    80002d70:	dc6080e7          	jalr	-570(ra) # 80000b32 <initlock>

  // Create linked list of buffers
  bcache.head.prev = &bcache.head;
    80002d74:	00017797          	auipc	a5,0x17
    80002d78:	76c78793          	addi	a5,a5,1900 # 8001a4e0 <bcache+0x8000>
    80002d7c:	00018717          	auipc	a4,0x18
    80002d80:	9cc70713          	addi	a4,a4,-1588 # 8001a748 <bcache+0x8268>
    80002d84:	2ae7b823          	sd	a4,688(a5)
  bcache.head.next = &bcache.head;
    80002d88:	2ae7bc23          	sd	a4,696(a5)
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    80002d8c:	0000f497          	auipc	s1,0xf
    80002d90:	76c48493          	addi	s1,s1,1900 # 800124f8 <bcache+0x18>
    b->next = bcache.head.next;
    80002d94:	893e                	mv	s2,a5
    b->prev = &bcache.head;
    80002d96:	89ba                	mv	s3,a4
    initsleeplock(&b->lock, "buffer");
    80002d98:	00005a17          	auipc	s4,0x5
    80002d9c:	748a0a13          	addi	s4,s4,1864 # 800084e0 <syscalls+0xc0>
    b->next = bcache.head.next;
    80002da0:	2b893783          	ld	a5,696(s2)
    80002da4:	e8bc                	sd	a5,80(s1)
    b->prev = &bcache.head;
    80002da6:	0534b423          	sd	s3,72(s1)
    initsleeplock(&b->lock, "buffer");
    80002daa:	85d2                	mv	a1,s4
    80002dac:	01048513          	addi	a0,s1,16
    80002db0:	00001097          	auipc	ra,0x1
    80002db4:	6a0080e7          	jalr	1696(ra) # 80004450 <initsleeplock>
    bcache.head.next->prev = b;
    80002db8:	2b893783          	ld	a5,696(s2)
    80002dbc:	e7a4                	sd	s1,72(a5)
    bcache.head.next = b;
    80002dbe:	2a993c23          	sd	s1,696(s2)
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    80002dc2:	45848493          	addi	s1,s1,1112
    80002dc6:	fd349de3          	bne	s1,s3,80002da0 <binit+0x54>
  }
}
    80002dca:	70a2                	ld	ra,40(sp)
    80002dcc:	7402                	ld	s0,32(sp)
    80002dce:	64e2                	ld	s1,24(sp)
    80002dd0:	6942                	ld	s2,16(sp)
    80002dd2:	69a2                	ld	s3,8(sp)
    80002dd4:	6a02                	ld	s4,0(sp)
    80002dd6:	6145                	addi	sp,sp,48
    80002dd8:	8082                	ret

0000000080002dda <bread>:
}

// Return a locked buf with the contents of the indicated block.
struct buf*
bread(uint dev, uint blockno)
{
    80002dda:	7179                	addi	sp,sp,-48
    80002ddc:	f406                	sd	ra,40(sp)
    80002dde:	f022                	sd	s0,32(sp)
    80002de0:	ec26                	sd	s1,24(sp)
    80002de2:	e84a                	sd	s2,16(sp)
    80002de4:	e44e                	sd	s3,8(sp)
    80002de6:	1800                	addi	s0,sp,48
    80002de8:	892a                	mv	s2,a0
    80002dea:	89ae                	mv	s3,a1
  acquire(&bcache.lock);
    80002dec:	0000f517          	auipc	a0,0xf
    80002df0:	6f450513          	addi	a0,a0,1780 # 800124e0 <bcache>
    80002df4:	ffffe097          	auipc	ra,0xffffe
    80002df8:	dce080e7          	jalr	-562(ra) # 80000bc2 <acquire>
  for(b = bcache.head.next; b != &bcache.head; b = b->next){
    80002dfc:	00018497          	auipc	s1,0x18
    80002e00:	99c4b483          	ld	s1,-1636(s1) # 8001a798 <bcache+0x82b8>
    80002e04:	00018797          	auipc	a5,0x18
    80002e08:	94478793          	addi	a5,a5,-1724 # 8001a748 <bcache+0x8268>
    80002e0c:	02f48f63          	beq	s1,a5,80002e4a <bread+0x70>
    80002e10:	873e                	mv	a4,a5
    80002e12:	a021                	j	80002e1a <bread+0x40>
    80002e14:	68a4                	ld	s1,80(s1)
    80002e16:	02e48a63          	beq	s1,a4,80002e4a <bread+0x70>
    if(b->dev == dev && b->blockno == blockno){
    80002e1a:	449c                	lw	a5,8(s1)
    80002e1c:	ff279ce3          	bne	a5,s2,80002e14 <bread+0x3a>
    80002e20:	44dc                	lw	a5,12(s1)
    80002e22:	ff3799e3          	bne	a5,s3,80002e14 <bread+0x3a>
      b->refcnt++;
    80002e26:	40bc                	lw	a5,64(s1)
    80002e28:	2785                	addiw	a5,a5,1
    80002e2a:	c0bc                	sw	a5,64(s1)
      release(&bcache.lock);
    80002e2c:	0000f517          	auipc	a0,0xf
    80002e30:	6b450513          	addi	a0,a0,1716 # 800124e0 <bcache>
    80002e34:	ffffe097          	auipc	ra,0xffffe
    80002e38:	e42080e7          	jalr	-446(ra) # 80000c76 <release>
      acquiresleep(&b->lock);
    80002e3c:	01048513          	addi	a0,s1,16
    80002e40:	00001097          	auipc	ra,0x1
    80002e44:	64a080e7          	jalr	1610(ra) # 8000448a <acquiresleep>
      return b;
    80002e48:	a8b9                	j	80002ea6 <bread+0xcc>
  for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
    80002e4a:	00018497          	auipc	s1,0x18
    80002e4e:	9464b483          	ld	s1,-1722(s1) # 8001a790 <bcache+0x82b0>
    80002e52:	00018797          	auipc	a5,0x18
    80002e56:	8f678793          	addi	a5,a5,-1802 # 8001a748 <bcache+0x8268>
    80002e5a:	00f48863          	beq	s1,a5,80002e6a <bread+0x90>
    80002e5e:	873e                	mv	a4,a5
    if(b->refcnt == 0) {
    80002e60:	40bc                	lw	a5,64(s1)
    80002e62:	cf81                	beqz	a5,80002e7a <bread+0xa0>
  for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
    80002e64:	64a4                	ld	s1,72(s1)
    80002e66:	fee49de3          	bne	s1,a4,80002e60 <bread+0x86>
  panic("bget: no buffers");
    80002e6a:	00005517          	auipc	a0,0x5
    80002e6e:	67e50513          	addi	a0,a0,1662 # 800084e8 <syscalls+0xc8>
    80002e72:	ffffd097          	auipc	ra,0xffffd
    80002e76:	6ba080e7          	jalr	1722(ra) # 8000052c <panic>
      b->dev = dev;
    80002e7a:	0124a423          	sw	s2,8(s1)
      b->blockno = blockno;
    80002e7e:	0134a623          	sw	s3,12(s1)
      b->valid = 0;
    80002e82:	0004a023          	sw	zero,0(s1)
      b->refcnt = 1;
    80002e86:	4785                	li	a5,1
    80002e88:	c0bc                	sw	a5,64(s1)
      release(&bcache.lock);
    80002e8a:	0000f517          	auipc	a0,0xf
    80002e8e:	65650513          	addi	a0,a0,1622 # 800124e0 <bcache>
    80002e92:	ffffe097          	auipc	ra,0xffffe
    80002e96:	de4080e7          	jalr	-540(ra) # 80000c76 <release>
      acquiresleep(&b->lock);
    80002e9a:	01048513          	addi	a0,s1,16
    80002e9e:	00001097          	auipc	ra,0x1
    80002ea2:	5ec080e7          	jalr	1516(ra) # 8000448a <acquiresleep>
  struct buf *b;

  b = bget(dev, blockno);
  if(!b->valid) {
    80002ea6:	409c                	lw	a5,0(s1)
    80002ea8:	cb89                	beqz	a5,80002eba <bread+0xe0>
    virtio_disk_rw(b, 0);
    b->valid = 1;
  }
  return b;
}
    80002eaa:	8526                	mv	a0,s1
    80002eac:	70a2                	ld	ra,40(sp)
    80002eae:	7402                	ld	s0,32(sp)
    80002eb0:	64e2                	ld	s1,24(sp)
    80002eb2:	6942                	ld	s2,16(sp)
    80002eb4:	69a2                	ld	s3,8(sp)
    80002eb6:	6145                	addi	sp,sp,48
    80002eb8:	8082                	ret
    virtio_disk_rw(b, 0);
    80002eba:	4581                	li	a1,0
    80002ebc:	8526                	mv	a0,s1
    80002ebe:	00003097          	auipc	ra,0x3
    80002ec2:	184080e7          	jalr	388(ra) # 80006042 <virtio_disk_rw>
    b->valid = 1;
    80002ec6:	4785                	li	a5,1
    80002ec8:	c09c                	sw	a5,0(s1)
  return b;
    80002eca:	b7c5                	j	80002eaa <bread+0xd0>

0000000080002ecc <bwrite>:

// Write b's contents to disk.  Must be locked.
void
bwrite(struct buf *b)
{
    80002ecc:	1101                	addi	sp,sp,-32
    80002ece:	ec06                	sd	ra,24(sp)
    80002ed0:	e822                	sd	s0,16(sp)
    80002ed2:	e426                	sd	s1,8(sp)
    80002ed4:	1000                	addi	s0,sp,32
    80002ed6:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    80002ed8:	0541                	addi	a0,a0,16
    80002eda:	00001097          	auipc	ra,0x1
    80002ede:	64a080e7          	jalr	1610(ra) # 80004524 <holdingsleep>
    80002ee2:	cd01                	beqz	a0,80002efa <bwrite+0x2e>
    panic("bwrite");
  virtio_disk_rw(b, 1);
    80002ee4:	4585                	li	a1,1
    80002ee6:	8526                	mv	a0,s1
    80002ee8:	00003097          	auipc	ra,0x3
    80002eec:	15a080e7          	jalr	346(ra) # 80006042 <virtio_disk_rw>
}
    80002ef0:	60e2                	ld	ra,24(sp)
    80002ef2:	6442                	ld	s0,16(sp)
    80002ef4:	64a2                	ld	s1,8(sp)
    80002ef6:	6105                	addi	sp,sp,32
    80002ef8:	8082                	ret
    panic("bwrite");
    80002efa:	00005517          	auipc	a0,0x5
    80002efe:	60650513          	addi	a0,a0,1542 # 80008500 <syscalls+0xe0>
    80002f02:	ffffd097          	auipc	ra,0xffffd
    80002f06:	62a080e7          	jalr	1578(ra) # 8000052c <panic>

0000000080002f0a <brelse>:

// Release a locked buffer.
// Move to the head of the most-recently-used list.
void
brelse(struct buf *b)
{
    80002f0a:	1101                	addi	sp,sp,-32
    80002f0c:	ec06                	sd	ra,24(sp)
    80002f0e:	e822                	sd	s0,16(sp)
    80002f10:	e426                	sd	s1,8(sp)
    80002f12:	e04a                	sd	s2,0(sp)
    80002f14:	1000                	addi	s0,sp,32
    80002f16:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    80002f18:	01050913          	addi	s2,a0,16
    80002f1c:	854a                	mv	a0,s2
    80002f1e:	00001097          	auipc	ra,0x1
    80002f22:	606080e7          	jalr	1542(ra) # 80004524 <holdingsleep>
    80002f26:	c92d                	beqz	a0,80002f98 <brelse+0x8e>
    panic("brelse");

  releasesleep(&b->lock);
    80002f28:	854a                	mv	a0,s2
    80002f2a:	00001097          	auipc	ra,0x1
    80002f2e:	5b6080e7          	jalr	1462(ra) # 800044e0 <releasesleep>

  acquire(&bcache.lock);
    80002f32:	0000f517          	auipc	a0,0xf
    80002f36:	5ae50513          	addi	a0,a0,1454 # 800124e0 <bcache>
    80002f3a:	ffffe097          	auipc	ra,0xffffe
    80002f3e:	c88080e7          	jalr	-888(ra) # 80000bc2 <acquire>
  b->refcnt--;
    80002f42:	40bc                	lw	a5,64(s1)
    80002f44:	37fd                	addiw	a5,a5,-1
    80002f46:	0007871b          	sext.w	a4,a5
    80002f4a:	c0bc                	sw	a5,64(s1)
  if (b->refcnt == 0) {
    80002f4c:	eb05                	bnez	a4,80002f7c <brelse+0x72>
    // no one is waiting for it.
    b->next->prev = b->prev;
    80002f4e:	68bc                	ld	a5,80(s1)
    80002f50:	64b8                	ld	a4,72(s1)
    80002f52:	e7b8                	sd	a4,72(a5)
    b->prev->next = b->next;
    80002f54:	64bc                	ld	a5,72(s1)
    80002f56:	68b8                	ld	a4,80(s1)
    80002f58:	ebb8                	sd	a4,80(a5)
    b->next = bcache.head.next;
    80002f5a:	00017797          	auipc	a5,0x17
    80002f5e:	58678793          	addi	a5,a5,1414 # 8001a4e0 <bcache+0x8000>
    80002f62:	2b87b703          	ld	a4,696(a5)
    80002f66:	e8b8                	sd	a4,80(s1)
    b->prev = &bcache.head;
    80002f68:	00017717          	auipc	a4,0x17
    80002f6c:	7e070713          	addi	a4,a4,2016 # 8001a748 <bcache+0x8268>
    80002f70:	e4b8                	sd	a4,72(s1)
    bcache.head.next->prev = b;
    80002f72:	2b87b703          	ld	a4,696(a5)
    80002f76:	e724                	sd	s1,72(a4)
    bcache.head.next = b;
    80002f78:	2a97bc23          	sd	s1,696(a5)
  }
  
  release(&bcache.lock);
    80002f7c:	0000f517          	auipc	a0,0xf
    80002f80:	56450513          	addi	a0,a0,1380 # 800124e0 <bcache>
    80002f84:	ffffe097          	auipc	ra,0xffffe
    80002f88:	cf2080e7          	jalr	-782(ra) # 80000c76 <release>
}
    80002f8c:	60e2                	ld	ra,24(sp)
    80002f8e:	6442                	ld	s0,16(sp)
    80002f90:	64a2                	ld	s1,8(sp)
    80002f92:	6902                	ld	s2,0(sp)
    80002f94:	6105                	addi	sp,sp,32
    80002f96:	8082                	ret
    panic("brelse");
    80002f98:	00005517          	auipc	a0,0x5
    80002f9c:	57050513          	addi	a0,a0,1392 # 80008508 <syscalls+0xe8>
    80002fa0:	ffffd097          	auipc	ra,0xffffd
    80002fa4:	58c080e7          	jalr	1420(ra) # 8000052c <panic>

0000000080002fa8 <bpin>:

void
bpin(struct buf *b) {
    80002fa8:	1101                	addi	sp,sp,-32
    80002faa:	ec06                	sd	ra,24(sp)
    80002fac:	e822                	sd	s0,16(sp)
    80002fae:	e426                	sd	s1,8(sp)
    80002fb0:	1000                	addi	s0,sp,32
    80002fb2:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    80002fb4:	0000f517          	auipc	a0,0xf
    80002fb8:	52c50513          	addi	a0,a0,1324 # 800124e0 <bcache>
    80002fbc:	ffffe097          	auipc	ra,0xffffe
    80002fc0:	c06080e7          	jalr	-1018(ra) # 80000bc2 <acquire>
  b->refcnt++;
    80002fc4:	40bc                	lw	a5,64(s1)
    80002fc6:	2785                	addiw	a5,a5,1
    80002fc8:	c0bc                	sw	a5,64(s1)
  release(&bcache.lock);
    80002fca:	0000f517          	auipc	a0,0xf
    80002fce:	51650513          	addi	a0,a0,1302 # 800124e0 <bcache>
    80002fd2:	ffffe097          	auipc	ra,0xffffe
    80002fd6:	ca4080e7          	jalr	-860(ra) # 80000c76 <release>
}
    80002fda:	60e2                	ld	ra,24(sp)
    80002fdc:	6442                	ld	s0,16(sp)
    80002fde:	64a2                	ld	s1,8(sp)
    80002fe0:	6105                	addi	sp,sp,32
    80002fe2:	8082                	ret

0000000080002fe4 <bunpin>:

void
bunpin(struct buf *b) {
    80002fe4:	1101                	addi	sp,sp,-32
    80002fe6:	ec06                	sd	ra,24(sp)
    80002fe8:	e822                	sd	s0,16(sp)
    80002fea:	e426                	sd	s1,8(sp)
    80002fec:	1000                	addi	s0,sp,32
    80002fee:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    80002ff0:	0000f517          	auipc	a0,0xf
    80002ff4:	4f050513          	addi	a0,a0,1264 # 800124e0 <bcache>
    80002ff8:	ffffe097          	auipc	ra,0xffffe
    80002ffc:	bca080e7          	jalr	-1078(ra) # 80000bc2 <acquire>
  b->refcnt--;
    80003000:	40bc                	lw	a5,64(s1)
    80003002:	37fd                	addiw	a5,a5,-1
    80003004:	c0bc                	sw	a5,64(s1)
  release(&bcache.lock);
    80003006:	0000f517          	auipc	a0,0xf
    8000300a:	4da50513          	addi	a0,a0,1242 # 800124e0 <bcache>
    8000300e:	ffffe097          	auipc	ra,0xffffe
    80003012:	c68080e7          	jalr	-920(ra) # 80000c76 <release>
}
    80003016:	60e2                	ld	ra,24(sp)
    80003018:	6442                	ld	s0,16(sp)
    8000301a:	64a2                	ld	s1,8(sp)
    8000301c:	6105                	addi	sp,sp,32
    8000301e:	8082                	ret

0000000080003020 <bfree>:
}

// Free a disk block.
static void
bfree(int dev, uint b)
{
    80003020:	1101                	addi	sp,sp,-32
    80003022:	ec06                	sd	ra,24(sp)
    80003024:	e822                	sd	s0,16(sp)
    80003026:	e426                	sd	s1,8(sp)
    80003028:	e04a                	sd	s2,0(sp)
    8000302a:	1000                	addi	s0,sp,32
    8000302c:	84ae                	mv	s1,a1
  struct buf *bp;
  int bi, m;

  bp = bread(dev, BBLOCK(b, sb));
    8000302e:	00d5d59b          	srliw	a1,a1,0xd
    80003032:	00018797          	auipc	a5,0x18
    80003036:	b8a7a783          	lw	a5,-1142(a5) # 8001abbc <sb+0x1c>
    8000303a:	9dbd                	addw	a1,a1,a5
    8000303c:	00000097          	auipc	ra,0x0
    80003040:	d9e080e7          	jalr	-610(ra) # 80002dda <bread>
  bi = b % BPB;
  m = 1 << (bi % 8);
    80003044:	0074f713          	andi	a4,s1,7
    80003048:	4785                	li	a5,1
    8000304a:	00e797bb          	sllw	a5,a5,a4
  if((bp->data[bi/8] & m) == 0)
    8000304e:	14ce                	slli	s1,s1,0x33
    80003050:	90d9                	srli	s1,s1,0x36
    80003052:	00950733          	add	a4,a0,s1
    80003056:	05874703          	lbu	a4,88(a4)
    8000305a:	00e7f6b3          	and	a3,a5,a4
    8000305e:	c69d                	beqz	a3,8000308c <bfree+0x6c>
    80003060:	892a                	mv	s2,a0
    panic("freeing free block");
  bp->data[bi/8] &= ~m;
    80003062:	94aa                	add	s1,s1,a0
    80003064:	fff7c793          	not	a5,a5
    80003068:	8f7d                	and	a4,a4,a5
    8000306a:	04e48c23          	sb	a4,88(s1)
  log_write(bp);
    8000306e:	00001097          	auipc	ra,0x1
    80003072:	2f6080e7          	jalr	758(ra) # 80004364 <log_write>
  brelse(bp);
    80003076:	854a                	mv	a0,s2
    80003078:	00000097          	auipc	ra,0x0
    8000307c:	e92080e7          	jalr	-366(ra) # 80002f0a <brelse>
}
    80003080:	60e2                	ld	ra,24(sp)
    80003082:	6442                	ld	s0,16(sp)
    80003084:	64a2                	ld	s1,8(sp)
    80003086:	6902                	ld	s2,0(sp)
    80003088:	6105                	addi	sp,sp,32
    8000308a:	8082                	ret
    panic("freeing free block");
    8000308c:	00005517          	auipc	a0,0x5
    80003090:	48450513          	addi	a0,a0,1156 # 80008510 <syscalls+0xf0>
    80003094:	ffffd097          	auipc	ra,0xffffd
    80003098:	498080e7          	jalr	1176(ra) # 8000052c <panic>

000000008000309c <balloc>:
{
    8000309c:	711d                	addi	sp,sp,-96
    8000309e:	ec86                	sd	ra,88(sp)
    800030a0:	e8a2                	sd	s0,80(sp)
    800030a2:	e4a6                	sd	s1,72(sp)
    800030a4:	e0ca                	sd	s2,64(sp)
    800030a6:	fc4e                	sd	s3,56(sp)
    800030a8:	f852                	sd	s4,48(sp)
    800030aa:	f456                	sd	s5,40(sp)
    800030ac:	f05a                	sd	s6,32(sp)
    800030ae:	ec5e                	sd	s7,24(sp)
    800030b0:	e862                	sd	s8,16(sp)
    800030b2:	e466                	sd	s9,8(sp)
    800030b4:	1080                	addi	s0,sp,96
  for(b = 0; b < sb.size; b += BPB){
    800030b6:	00018797          	auipc	a5,0x18
    800030ba:	aee7a783          	lw	a5,-1298(a5) # 8001aba4 <sb+0x4>
    800030be:	cbc1                	beqz	a5,8000314e <balloc+0xb2>
    800030c0:	8baa                	mv	s7,a0
    800030c2:	4a81                	li	s5,0
    bp = bread(dev, BBLOCK(b, sb));
    800030c4:	00018b17          	auipc	s6,0x18
    800030c8:	adcb0b13          	addi	s6,s6,-1316 # 8001aba0 <sb>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    800030cc:	4c01                	li	s8,0
      m = 1 << (bi % 8);
    800030ce:	4985                	li	s3,1
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    800030d0:	6a09                	lui	s4,0x2
  for(b = 0; b < sb.size; b += BPB){
    800030d2:	6c89                	lui	s9,0x2
    800030d4:	a831                	j	800030f0 <balloc+0x54>
    brelse(bp);
    800030d6:	854a                	mv	a0,s2
    800030d8:	00000097          	auipc	ra,0x0
    800030dc:	e32080e7          	jalr	-462(ra) # 80002f0a <brelse>
  for(b = 0; b < sb.size; b += BPB){
    800030e0:	015c87bb          	addw	a5,s9,s5
    800030e4:	00078a9b          	sext.w	s5,a5
    800030e8:	004b2703          	lw	a4,4(s6)
    800030ec:	06eaf163          	bgeu	s5,a4,8000314e <balloc+0xb2>
    bp = bread(dev, BBLOCK(b, sb));
    800030f0:	41fad79b          	sraiw	a5,s5,0x1f
    800030f4:	0137d79b          	srliw	a5,a5,0x13
    800030f8:	015787bb          	addw	a5,a5,s5
    800030fc:	40d7d79b          	sraiw	a5,a5,0xd
    80003100:	01cb2583          	lw	a1,28(s6)
    80003104:	9dbd                	addw	a1,a1,a5
    80003106:	855e                	mv	a0,s7
    80003108:	00000097          	auipc	ra,0x0
    8000310c:	cd2080e7          	jalr	-814(ra) # 80002dda <bread>
    80003110:	892a                	mv	s2,a0
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80003112:	004b2503          	lw	a0,4(s6)
    80003116:	000a849b          	sext.w	s1,s5
    8000311a:	8762                	mv	a4,s8
    8000311c:	faa4fde3          	bgeu	s1,a0,800030d6 <balloc+0x3a>
      m = 1 << (bi % 8);
    80003120:	00777693          	andi	a3,a4,7
    80003124:	00d996bb          	sllw	a3,s3,a3
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    80003128:	41f7579b          	sraiw	a5,a4,0x1f
    8000312c:	01d7d79b          	srliw	a5,a5,0x1d
    80003130:	9fb9                	addw	a5,a5,a4
    80003132:	4037d79b          	sraiw	a5,a5,0x3
    80003136:	00f90633          	add	a2,s2,a5
    8000313a:	05864603          	lbu	a2,88(a2)
    8000313e:	00c6f5b3          	and	a1,a3,a2
    80003142:	cd91                	beqz	a1,8000315e <balloc+0xc2>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80003144:	2705                	addiw	a4,a4,1
    80003146:	2485                	addiw	s1,s1,1
    80003148:	fd471ae3          	bne	a4,s4,8000311c <balloc+0x80>
    8000314c:	b769                	j	800030d6 <balloc+0x3a>
  panic("balloc: out of blocks");
    8000314e:	00005517          	auipc	a0,0x5
    80003152:	3da50513          	addi	a0,a0,986 # 80008528 <syscalls+0x108>
    80003156:	ffffd097          	auipc	ra,0xffffd
    8000315a:	3d6080e7          	jalr	982(ra) # 8000052c <panic>
        bp->data[bi/8] |= m;  // Mark block in use.
    8000315e:	97ca                	add	a5,a5,s2
    80003160:	8e55                	or	a2,a2,a3
    80003162:	04c78c23          	sb	a2,88(a5)
        log_write(bp);
    80003166:	854a                	mv	a0,s2
    80003168:	00001097          	auipc	ra,0x1
    8000316c:	1fc080e7          	jalr	508(ra) # 80004364 <log_write>
        brelse(bp);
    80003170:	854a                	mv	a0,s2
    80003172:	00000097          	auipc	ra,0x0
    80003176:	d98080e7          	jalr	-616(ra) # 80002f0a <brelse>
  bp = bread(dev, bno);
    8000317a:	85a6                	mv	a1,s1
    8000317c:	855e                	mv	a0,s7
    8000317e:	00000097          	auipc	ra,0x0
    80003182:	c5c080e7          	jalr	-932(ra) # 80002dda <bread>
    80003186:	892a                	mv	s2,a0
  memset(bp->data, 0, BSIZE);
    80003188:	40000613          	li	a2,1024
    8000318c:	4581                	li	a1,0
    8000318e:	05850513          	addi	a0,a0,88
    80003192:	ffffe097          	auipc	ra,0xffffe
    80003196:	b2c080e7          	jalr	-1236(ra) # 80000cbe <memset>
  log_write(bp);
    8000319a:	854a                	mv	a0,s2
    8000319c:	00001097          	auipc	ra,0x1
    800031a0:	1c8080e7          	jalr	456(ra) # 80004364 <log_write>
  brelse(bp);
    800031a4:	854a                	mv	a0,s2
    800031a6:	00000097          	auipc	ra,0x0
    800031aa:	d64080e7          	jalr	-668(ra) # 80002f0a <brelse>
}
    800031ae:	8526                	mv	a0,s1
    800031b0:	60e6                	ld	ra,88(sp)
    800031b2:	6446                	ld	s0,80(sp)
    800031b4:	64a6                	ld	s1,72(sp)
    800031b6:	6906                	ld	s2,64(sp)
    800031b8:	79e2                	ld	s3,56(sp)
    800031ba:	7a42                	ld	s4,48(sp)
    800031bc:	7aa2                	ld	s5,40(sp)
    800031be:	7b02                	ld	s6,32(sp)
    800031c0:	6be2                	ld	s7,24(sp)
    800031c2:	6c42                	ld	s8,16(sp)
    800031c4:	6ca2                	ld	s9,8(sp)
    800031c6:	6125                	addi	sp,sp,96
    800031c8:	8082                	ret

00000000800031ca <bmap>:

// Return the disk block address of the nth block in inode ip.
// If there is no such block, bmap allocates one.
static uint
bmap(struct inode *ip, uint bn)
{
    800031ca:	7139                	addi	sp,sp,-64
    800031cc:	fc06                	sd	ra,56(sp)
    800031ce:	f822                	sd	s0,48(sp)
    800031d0:	f426                	sd	s1,40(sp)
    800031d2:	f04a                	sd	s2,32(sp)
    800031d4:	ec4e                	sd	s3,24(sp)
    800031d6:	e852                	sd	s4,16(sp)
    800031d8:	e456                	sd	s5,8(sp)
    800031da:	0080                	addi	s0,sp,64
    800031dc:	89aa                	mv	s3,a0
  uint addr, *a;
  struct buf *bp;

  if(bn < NDIRECT){
    800031de:	47a9                	li	a5,10
    800031e0:	08b7fd63          	bgeu	a5,a1,8000327a <bmap+0xb0>
    if((addr = ip->addrs[bn]) == 0)
      ip->addrs[bn] = addr = balloc(ip->dev);
    return addr;
  }
  bn -= NDIRECT;
    800031e4:	ff55849b          	addiw	s1,a1,-11
    800031e8:	0004871b          	sext.w	a4,s1

  if(bn < NINDIRECT){
    800031ec:	0ff00793          	li	a5,255
    800031f0:	0ae7f963          	bgeu	a5,a4,800032a2 <bmap+0xd8>
    }
    brelse(bp);
    return addr;
  }

  bn -= NINDIRECT;
    800031f4:	ef55849b          	addiw	s1,a1,-267
    800031f8:	0004871b          	sext.w	a4,s1
  if(bn < NDINDIRECT){
    800031fc:	67c1                	lui	a5,0x10
    800031fe:	16f77063          	bgeu	a4,a5,8000335e <bmap+0x194>
    // 二级间接索引的处理方法
    // 判断二级间接索引所在的位置是否有效
    if((addr = ip->addrs[NDIRECT + 1]) == 0)
    80003202:	08052583          	lw	a1,128(a0)
    80003206:	10058263          	beqz	a1,8000330a <bmap+0x140>
      // 无效 分配一个空闲块作为二级索引页
      ip->addrs[NDIRECT + 1] = addr = balloc(ip->dev);
    // 使用缓冲区bp读出二级索引页
    bp = bread(ip->dev, addr);
    8000320a:	0009a503          	lw	a0,0(s3)
    8000320e:	00000097          	auipc	ra,0x0
    80003212:	bcc080e7          	jalr	-1076(ra) # 80002dda <bread>
    80003216:	892a                	mv	s2,a0
    a = (uint*)bp->data;
    80003218:	05850a13          	addi	s4,a0,88
    // 判断一级间接索引所在位置是否有效
    if((addr = a[bn / NINDIRECT]) == 0){
    8000321c:	0084d79b          	srliw	a5,s1,0x8
    80003220:	078a                	slli	a5,a5,0x2
    80003222:	9a3e                	add	s4,s4,a5
    80003224:	000a2a83          	lw	s5,0(s4) # 2000 <_entry-0x7fffe000>
    80003228:	0e0a8b63          	beqz	s5,8000331e <bmap+0x154>
      a[bn / NINDIRECT] = addr = balloc(ip->dev);
      // 将修改后的buf写入日志
      log_write(bp);
    }
    // 释放buf缓冲区
    brelse(bp);
    8000322c:	854a                	mv	a0,s2
    8000322e:	00000097          	auipc	ra,0x0
    80003232:	cdc080e7          	jalr	-804(ra) # 80002f0a <brelse>
    // 使用缓冲区bp读出一级索引页
    bp = bread(ip->dev, addr);
    80003236:	85d6                	mv	a1,s5
    80003238:	0009a503          	lw	a0,0(s3)
    8000323c:	00000097          	auipc	ra,0x0
    80003240:	b9e080e7          	jalr	-1122(ra) # 80002dda <bread>
    80003244:	8a2a                	mv	s4,a0
    a = (uint*)bp->data;
    80003246:	05850793          	addi	a5,a0,88
    // 判断直接索引所在位置是否有效
    if((addr = a[bn % NINDIRECT]) == 0){
    8000324a:	0ff4f593          	zext.b	a1,s1
    8000324e:	058a                	slli	a1,a1,0x2
    80003250:	00b784b3          	add	s1,a5,a1
    80003254:	0004a903          	lw	s2,0(s1)
    80003258:	0e090363          	beqz	s2,8000333e <bmap+0x174>
      a[bn % NINDIRECT] = addr = balloc(ip->dev);
      // 将修改后的buf写入日志
      log_write(bp);
    }
    // 释放buf缓冲区
    brelse(bp);
    8000325c:	8552                	mv	a0,s4
    8000325e:	00000097          	auipc	ra,0x0
    80003262:	cac080e7          	jalr	-852(ra) # 80002f0a <brelse>
    // 返回找到的地址
    return addr;
  }

  panic("bmap: out of range");
}
    80003266:	854a                	mv	a0,s2
    80003268:	70e2                	ld	ra,56(sp)
    8000326a:	7442                	ld	s0,48(sp)
    8000326c:	74a2                	ld	s1,40(sp)
    8000326e:	7902                	ld	s2,32(sp)
    80003270:	69e2                	ld	s3,24(sp)
    80003272:	6a42                	ld	s4,16(sp)
    80003274:	6aa2                	ld	s5,8(sp)
    80003276:	6121                	addi	sp,sp,64
    80003278:	8082                	ret
    if((addr = ip->addrs[bn]) == 0)
    8000327a:	02059793          	slli	a5,a1,0x20
    8000327e:	01e7d593          	srli	a1,a5,0x1e
    80003282:	00b504b3          	add	s1,a0,a1
    80003286:	0504a903          	lw	s2,80(s1)
    8000328a:	fc091ee3          	bnez	s2,80003266 <bmap+0x9c>
      ip->addrs[bn] = addr = balloc(ip->dev);
    8000328e:	4108                	lw	a0,0(a0)
    80003290:	00000097          	auipc	ra,0x0
    80003294:	e0c080e7          	jalr	-500(ra) # 8000309c <balloc>
    80003298:	0005091b          	sext.w	s2,a0
    8000329c:	0524a823          	sw	s2,80(s1)
    800032a0:	b7d9                	j	80003266 <bmap+0x9c>
    if((addr = ip->addrs[NDIRECT]) == 0)
    800032a2:	5d6c                	lw	a1,124(a0)
    800032a4:	c98d                	beqz	a1,800032d6 <bmap+0x10c>
    bp = bread(ip->dev, addr);
    800032a6:	0009a503          	lw	a0,0(s3)
    800032aa:	00000097          	auipc	ra,0x0
    800032ae:	b30080e7          	jalr	-1232(ra) # 80002dda <bread>
    800032b2:	8a2a                	mv	s4,a0
    a = (uint*)bp->data;
    800032b4:	05850793          	addi	a5,a0,88
    if((addr = a[bn]) == 0){
    800032b8:	02049713          	slli	a4,s1,0x20
    800032bc:	01e75493          	srli	s1,a4,0x1e
    800032c0:	94be                	add	s1,s1,a5
    800032c2:	0004a903          	lw	s2,0(s1)
    800032c6:	02090263          	beqz	s2,800032ea <bmap+0x120>
    brelse(bp);
    800032ca:	8552                	mv	a0,s4
    800032cc:	00000097          	auipc	ra,0x0
    800032d0:	c3e080e7          	jalr	-962(ra) # 80002f0a <brelse>
    return addr;
    800032d4:	bf49                	j	80003266 <bmap+0x9c>
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    800032d6:	4108                	lw	a0,0(a0)
    800032d8:	00000097          	auipc	ra,0x0
    800032dc:	dc4080e7          	jalr	-572(ra) # 8000309c <balloc>
    800032e0:	0005059b          	sext.w	a1,a0
    800032e4:	06b9ae23          	sw	a1,124(s3)
    800032e8:	bf7d                	j	800032a6 <bmap+0xdc>
      a[bn] = addr = balloc(ip->dev);
    800032ea:	0009a503          	lw	a0,0(s3)
    800032ee:	00000097          	auipc	ra,0x0
    800032f2:	dae080e7          	jalr	-594(ra) # 8000309c <balloc>
    800032f6:	0005091b          	sext.w	s2,a0
    800032fa:	0124a023          	sw	s2,0(s1)
      log_write(bp);
    800032fe:	8552                	mv	a0,s4
    80003300:	00001097          	auipc	ra,0x1
    80003304:	064080e7          	jalr	100(ra) # 80004364 <log_write>
    80003308:	b7c9                	j	800032ca <bmap+0x100>
      ip->addrs[NDIRECT + 1] = addr = balloc(ip->dev);
    8000330a:	4108                	lw	a0,0(a0)
    8000330c:	00000097          	auipc	ra,0x0
    80003310:	d90080e7          	jalr	-624(ra) # 8000309c <balloc>
    80003314:	0005059b          	sext.w	a1,a0
    80003318:	08b9a023          	sw	a1,128(s3)
    8000331c:	b5fd                	j	8000320a <bmap+0x40>
      a[bn / NINDIRECT] = addr = balloc(ip->dev);
    8000331e:	0009a503          	lw	a0,0(s3)
    80003322:	00000097          	auipc	ra,0x0
    80003326:	d7a080e7          	jalr	-646(ra) # 8000309c <balloc>
    8000332a:	00050a9b          	sext.w	s5,a0
    8000332e:	015a2023          	sw	s5,0(s4)
      log_write(bp);
    80003332:	854a                	mv	a0,s2
    80003334:	00001097          	auipc	ra,0x1
    80003338:	030080e7          	jalr	48(ra) # 80004364 <log_write>
    8000333c:	bdc5                	j	8000322c <bmap+0x62>
      a[bn % NINDIRECT] = addr = balloc(ip->dev);
    8000333e:	0009a503          	lw	a0,0(s3)
    80003342:	00000097          	auipc	ra,0x0
    80003346:	d5a080e7          	jalr	-678(ra) # 8000309c <balloc>
    8000334a:	0005091b          	sext.w	s2,a0
    8000334e:	0124a023          	sw	s2,0(s1)
      log_write(bp);
    80003352:	8552                	mv	a0,s4
    80003354:	00001097          	auipc	ra,0x1
    80003358:	010080e7          	jalr	16(ra) # 80004364 <log_write>
    8000335c:	b701                	j	8000325c <bmap+0x92>
  panic("bmap: out of range");
    8000335e:	00005517          	auipc	a0,0x5
    80003362:	1e250513          	addi	a0,a0,482 # 80008540 <syscalls+0x120>
    80003366:	ffffd097          	auipc	ra,0xffffd
    8000336a:	1c6080e7          	jalr	454(ra) # 8000052c <panic>

000000008000336e <iget>:
{
    8000336e:	7179                	addi	sp,sp,-48
    80003370:	f406                	sd	ra,40(sp)
    80003372:	f022                	sd	s0,32(sp)
    80003374:	ec26                	sd	s1,24(sp)
    80003376:	e84a                	sd	s2,16(sp)
    80003378:	e44e                	sd	s3,8(sp)
    8000337a:	e052                	sd	s4,0(sp)
    8000337c:	1800                	addi	s0,sp,48
    8000337e:	89aa                	mv	s3,a0
    80003380:	8a2e                	mv	s4,a1
  acquire(&icache.lock);
    80003382:	00018517          	auipc	a0,0x18
    80003386:	83e50513          	addi	a0,a0,-1986 # 8001abc0 <icache>
    8000338a:	ffffe097          	auipc	ra,0xffffe
    8000338e:	838080e7          	jalr	-1992(ra) # 80000bc2 <acquire>
  empty = 0;
    80003392:	4901                	li	s2,0
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    80003394:	00018497          	auipc	s1,0x18
    80003398:	84448493          	addi	s1,s1,-1980 # 8001abd8 <icache+0x18>
    8000339c:	00019697          	auipc	a3,0x19
    800033a0:	2cc68693          	addi	a3,a3,716 # 8001c668 <log>
    800033a4:	a039                	j	800033b2 <iget+0x44>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    800033a6:	02090b63          	beqz	s2,800033dc <iget+0x6e>
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    800033aa:	08848493          	addi	s1,s1,136
    800033ae:	02d48a63          	beq	s1,a3,800033e2 <iget+0x74>
    if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
    800033b2:	449c                	lw	a5,8(s1)
    800033b4:	fef059e3          	blez	a5,800033a6 <iget+0x38>
    800033b8:	4098                	lw	a4,0(s1)
    800033ba:	ff3716e3          	bne	a4,s3,800033a6 <iget+0x38>
    800033be:	40d8                	lw	a4,4(s1)
    800033c0:	ff4713e3          	bne	a4,s4,800033a6 <iget+0x38>
      ip->ref++;
    800033c4:	2785                	addiw	a5,a5,1 # 10001 <_entry-0x7ffeffff>
    800033c6:	c49c                	sw	a5,8(s1)
      release(&icache.lock);
    800033c8:	00017517          	auipc	a0,0x17
    800033cc:	7f850513          	addi	a0,a0,2040 # 8001abc0 <icache>
    800033d0:	ffffe097          	auipc	ra,0xffffe
    800033d4:	8a6080e7          	jalr	-1882(ra) # 80000c76 <release>
      return ip;
    800033d8:	8926                	mv	s2,s1
    800033da:	a03d                	j	80003408 <iget+0x9a>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    800033dc:	f7f9                	bnez	a5,800033aa <iget+0x3c>
    800033de:	8926                	mv	s2,s1
    800033e0:	b7e9                	j	800033aa <iget+0x3c>
  if(empty == 0)
    800033e2:	02090c63          	beqz	s2,8000341a <iget+0xac>
  ip->dev = dev;
    800033e6:	01392023          	sw	s3,0(s2)
  ip->inum = inum;
    800033ea:	01492223          	sw	s4,4(s2)
  ip->ref = 1;
    800033ee:	4785                	li	a5,1
    800033f0:	00f92423          	sw	a5,8(s2)
  ip->valid = 0;
    800033f4:	04092023          	sw	zero,64(s2)
  release(&icache.lock);
    800033f8:	00017517          	auipc	a0,0x17
    800033fc:	7c850513          	addi	a0,a0,1992 # 8001abc0 <icache>
    80003400:	ffffe097          	auipc	ra,0xffffe
    80003404:	876080e7          	jalr	-1930(ra) # 80000c76 <release>
}
    80003408:	854a                	mv	a0,s2
    8000340a:	70a2                	ld	ra,40(sp)
    8000340c:	7402                	ld	s0,32(sp)
    8000340e:	64e2                	ld	s1,24(sp)
    80003410:	6942                	ld	s2,16(sp)
    80003412:	69a2                	ld	s3,8(sp)
    80003414:	6a02                	ld	s4,0(sp)
    80003416:	6145                	addi	sp,sp,48
    80003418:	8082                	ret
    panic("iget: no inodes");
    8000341a:	00005517          	auipc	a0,0x5
    8000341e:	13e50513          	addi	a0,a0,318 # 80008558 <syscalls+0x138>
    80003422:	ffffd097          	auipc	ra,0xffffd
    80003426:	10a080e7          	jalr	266(ra) # 8000052c <panic>

000000008000342a <fsinit>:
fsinit(int dev) {
    8000342a:	7179                	addi	sp,sp,-48
    8000342c:	f406                	sd	ra,40(sp)
    8000342e:	f022                	sd	s0,32(sp)
    80003430:	ec26                	sd	s1,24(sp)
    80003432:	e84a                	sd	s2,16(sp)
    80003434:	e44e                	sd	s3,8(sp)
    80003436:	1800                	addi	s0,sp,48
    80003438:	892a                	mv	s2,a0
  bp = bread(dev, 1);
    8000343a:	4585                	li	a1,1
    8000343c:	00000097          	auipc	ra,0x0
    80003440:	99e080e7          	jalr	-1634(ra) # 80002dda <bread>
    80003444:	84aa                	mv	s1,a0
  memmove(sb, bp->data, sizeof(*sb));
    80003446:	00017997          	auipc	s3,0x17
    8000344a:	75a98993          	addi	s3,s3,1882 # 8001aba0 <sb>
    8000344e:	02000613          	li	a2,32
    80003452:	05850593          	addi	a1,a0,88
    80003456:	854e                	mv	a0,s3
    80003458:	ffffe097          	auipc	ra,0xffffe
    8000345c:	8c2080e7          	jalr	-1854(ra) # 80000d1a <memmove>
  brelse(bp);
    80003460:	8526                	mv	a0,s1
    80003462:	00000097          	auipc	ra,0x0
    80003466:	aa8080e7          	jalr	-1368(ra) # 80002f0a <brelse>
  if(sb.magic != FSMAGIC)
    8000346a:	0009a703          	lw	a4,0(s3)
    8000346e:	102037b7          	lui	a5,0x10203
    80003472:	04078793          	addi	a5,a5,64 # 10203040 <_entry-0x6fdfcfc0>
    80003476:	02f71263          	bne	a4,a5,8000349a <fsinit+0x70>
  initlog(dev, &sb);
    8000347a:	00017597          	auipc	a1,0x17
    8000347e:	72658593          	addi	a1,a1,1830 # 8001aba0 <sb>
    80003482:	854a                	mv	a0,s2
    80003484:	00001097          	auipc	ra,0x1
    80003488:	c64080e7          	jalr	-924(ra) # 800040e8 <initlog>
}
    8000348c:	70a2                	ld	ra,40(sp)
    8000348e:	7402                	ld	s0,32(sp)
    80003490:	64e2                	ld	s1,24(sp)
    80003492:	6942                	ld	s2,16(sp)
    80003494:	69a2                	ld	s3,8(sp)
    80003496:	6145                	addi	sp,sp,48
    80003498:	8082                	ret
    panic("invalid file system");
    8000349a:	00005517          	auipc	a0,0x5
    8000349e:	0ce50513          	addi	a0,a0,206 # 80008568 <syscalls+0x148>
    800034a2:	ffffd097          	auipc	ra,0xffffd
    800034a6:	08a080e7          	jalr	138(ra) # 8000052c <panic>

00000000800034aa <iinit>:
{
    800034aa:	7179                	addi	sp,sp,-48
    800034ac:	f406                	sd	ra,40(sp)
    800034ae:	f022                	sd	s0,32(sp)
    800034b0:	ec26                	sd	s1,24(sp)
    800034b2:	e84a                	sd	s2,16(sp)
    800034b4:	e44e                	sd	s3,8(sp)
    800034b6:	1800                	addi	s0,sp,48
  initlock(&icache.lock, "icache");
    800034b8:	00005597          	auipc	a1,0x5
    800034bc:	0c858593          	addi	a1,a1,200 # 80008580 <syscalls+0x160>
    800034c0:	00017517          	auipc	a0,0x17
    800034c4:	70050513          	addi	a0,a0,1792 # 8001abc0 <icache>
    800034c8:	ffffd097          	auipc	ra,0xffffd
    800034cc:	66a080e7          	jalr	1642(ra) # 80000b32 <initlock>
  for(i = 0; i < NINODE; i++) {
    800034d0:	00017497          	auipc	s1,0x17
    800034d4:	71848493          	addi	s1,s1,1816 # 8001abe8 <icache+0x28>
    800034d8:	00019997          	auipc	s3,0x19
    800034dc:	1a098993          	addi	s3,s3,416 # 8001c678 <log+0x10>
    initsleeplock(&icache.inode[i].lock, "inode");
    800034e0:	00005917          	auipc	s2,0x5
    800034e4:	0a890913          	addi	s2,s2,168 # 80008588 <syscalls+0x168>
    800034e8:	85ca                	mv	a1,s2
    800034ea:	8526                	mv	a0,s1
    800034ec:	00001097          	auipc	ra,0x1
    800034f0:	f64080e7          	jalr	-156(ra) # 80004450 <initsleeplock>
  for(i = 0; i < NINODE; i++) {
    800034f4:	08848493          	addi	s1,s1,136
    800034f8:	ff3498e3          	bne	s1,s3,800034e8 <iinit+0x3e>
}
    800034fc:	70a2                	ld	ra,40(sp)
    800034fe:	7402                	ld	s0,32(sp)
    80003500:	64e2                	ld	s1,24(sp)
    80003502:	6942                	ld	s2,16(sp)
    80003504:	69a2                	ld	s3,8(sp)
    80003506:	6145                	addi	sp,sp,48
    80003508:	8082                	ret

000000008000350a <ialloc>:
{
    8000350a:	715d                	addi	sp,sp,-80
    8000350c:	e486                	sd	ra,72(sp)
    8000350e:	e0a2                	sd	s0,64(sp)
    80003510:	fc26                	sd	s1,56(sp)
    80003512:	f84a                	sd	s2,48(sp)
    80003514:	f44e                	sd	s3,40(sp)
    80003516:	f052                	sd	s4,32(sp)
    80003518:	ec56                	sd	s5,24(sp)
    8000351a:	e85a                	sd	s6,16(sp)
    8000351c:	e45e                	sd	s7,8(sp)
    8000351e:	0880                	addi	s0,sp,80
  for(inum = 1; inum < sb.ninodes; inum++){
    80003520:	00017717          	auipc	a4,0x17
    80003524:	68c72703          	lw	a4,1676(a4) # 8001abac <sb+0xc>
    80003528:	4785                	li	a5,1
    8000352a:	04e7fa63          	bgeu	a5,a4,8000357e <ialloc+0x74>
    8000352e:	8aaa                	mv	s5,a0
    80003530:	8bae                	mv	s7,a1
    80003532:	4485                	li	s1,1
    bp = bread(dev, IBLOCK(inum, sb));
    80003534:	00017a17          	auipc	s4,0x17
    80003538:	66ca0a13          	addi	s4,s4,1644 # 8001aba0 <sb>
    8000353c:	00048b1b          	sext.w	s6,s1
    80003540:	0044d593          	srli	a1,s1,0x4
    80003544:	018a2783          	lw	a5,24(s4)
    80003548:	9dbd                	addw	a1,a1,a5
    8000354a:	8556                	mv	a0,s5
    8000354c:	00000097          	auipc	ra,0x0
    80003550:	88e080e7          	jalr	-1906(ra) # 80002dda <bread>
    80003554:	892a                	mv	s2,a0
    dip = (struct dinode*)bp->data + inum%IPB;
    80003556:	05850993          	addi	s3,a0,88
    8000355a:	00f4f793          	andi	a5,s1,15
    8000355e:	079a                	slli	a5,a5,0x6
    80003560:	99be                	add	s3,s3,a5
    if(dip->type == 0){  // a free inode
    80003562:	00099783          	lh	a5,0(s3)
    80003566:	c785                	beqz	a5,8000358e <ialloc+0x84>
    brelse(bp);
    80003568:	00000097          	auipc	ra,0x0
    8000356c:	9a2080e7          	jalr	-1630(ra) # 80002f0a <brelse>
  for(inum = 1; inum < sb.ninodes; inum++){
    80003570:	0485                	addi	s1,s1,1
    80003572:	00ca2703          	lw	a4,12(s4)
    80003576:	0004879b          	sext.w	a5,s1
    8000357a:	fce7e1e3          	bltu	a5,a4,8000353c <ialloc+0x32>
  panic("ialloc: no inodes");
    8000357e:	00005517          	auipc	a0,0x5
    80003582:	01250513          	addi	a0,a0,18 # 80008590 <syscalls+0x170>
    80003586:	ffffd097          	auipc	ra,0xffffd
    8000358a:	fa6080e7          	jalr	-90(ra) # 8000052c <panic>
      memset(dip, 0, sizeof(*dip));
    8000358e:	04000613          	li	a2,64
    80003592:	4581                	li	a1,0
    80003594:	854e                	mv	a0,s3
    80003596:	ffffd097          	auipc	ra,0xffffd
    8000359a:	728080e7          	jalr	1832(ra) # 80000cbe <memset>
      dip->type = type;
    8000359e:	01799023          	sh	s7,0(s3)
      log_write(bp);   // mark it allocated on the disk
    800035a2:	854a                	mv	a0,s2
    800035a4:	00001097          	auipc	ra,0x1
    800035a8:	dc0080e7          	jalr	-576(ra) # 80004364 <log_write>
      brelse(bp);
    800035ac:	854a                	mv	a0,s2
    800035ae:	00000097          	auipc	ra,0x0
    800035b2:	95c080e7          	jalr	-1700(ra) # 80002f0a <brelse>
      return iget(dev, inum);
    800035b6:	85da                	mv	a1,s6
    800035b8:	8556                	mv	a0,s5
    800035ba:	00000097          	auipc	ra,0x0
    800035be:	db4080e7          	jalr	-588(ra) # 8000336e <iget>
}
    800035c2:	60a6                	ld	ra,72(sp)
    800035c4:	6406                	ld	s0,64(sp)
    800035c6:	74e2                	ld	s1,56(sp)
    800035c8:	7942                	ld	s2,48(sp)
    800035ca:	79a2                	ld	s3,40(sp)
    800035cc:	7a02                	ld	s4,32(sp)
    800035ce:	6ae2                	ld	s5,24(sp)
    800035d0:	6b42                	ld	s6,16(sp)
    800035d2:	6ba2                	ld	s7,8(sp)
    800035d4:	6161                	addi	sp,sp,80
    800035d6:	8082                	ret

00000000800035d8 <iupdate>:
{
    800035d8:	1101                	addi	sp,sp,-32
    800035da:	ec06                	sd	ra,24(sp)
    800035dc:	e822                	sd	s0,16(sp)
    800035de:	e426                	sd	s1,8(sp)
    800035e0:	e04a                	sd	s2,0(sp)
    800035e2:	1000                	addi	s0,sp,32
    800035e4:	84aa                	mv	s1,a0
  bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    800035e6:	415c                	lw	a5,4(a0)
    800035e8:	0047d79b          	srliw	a5,a5,0x4
    800035ec:	00017597          	auipc	a1,0x17
    800035f0:	5cc5a583          	lw	a1,1484(a1) # 8001abb8 <sb+0x18>
    800035f4:	9dbd                	addw	a1,a1,a5
    800035f6:	4108                	lw	a0,0(a0)
    800035f8:	fffff097          	auipc	ra,0xfffff
    800035fc:	7e2080e7          	jalr	2018(ra) # 80002dda <bread>
    80003600:	892a                	mv	s2,a0
  dip = (struct dinode*)bp->data + ip->inum%IPB;
    80003602:	05850793          	addi	a5,a0,88
    80003606:	40d8                	lw	a4,4(s1)
    80003608:	8b3d                	andi	a4,a4,15
    8000360a:	071a                	slli	a4,a4,0x6
    8000360c:	97ba                	add	a5,a5,a4
  dip->type = ip->type;
    8000360e:	04449703          	lh	a4,68(s1)
    80003612:	00e79023          	sh	a4,0(a5)
  dip->major = ip->major;
    80003616:	04649703          	lh	a4,70(s1)
    8000361a:	00e79123          	sh	a4,2(a5)
  dip->minor = ip->minor;
    8000361e:	04849703          	lh	a4,72(s1)
    80003622:	00e79223          	sh	a4,4(a5)
  dip->nlink = ip->nlink;
    80003626:	04a49703          	lh	a4,74(s1)
    8000362a:	00e79323          	sh	a4,6(a5)
  dip->size = ip->size;
    8000362e:	44f8                	lw	a4,76(s1)
    80003630:	c798                	sw	a4,8(a5)
  memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
    80003632:	03400613          	li	a2,52
    80003636:	05048593          	addi	a1,s1,80
    8000363a:	00c78513          	addi	a0,a5,12
    8000363e:	ffffd097          	auipc	ra,0xffffd
    80003642:	6dc080e7          	jalr	1756(ra) # 80000d1a <memmove>
  log_write(bp);
    80003646:	854a                	mv	a0,s2
    80003648:	00001097          	auipc	ra,0x1
    8000364c:	d1c080e7          	jalr	-740(ra) # 80004364 <log_write>
  brelse(bp);
    80003650:	854a                	mv	a0,s2
    80003652:	00000097          	auipc	ra,0x0
    80003656:	8b8080e7          	jalr	-1864(ra) # 80002f0a <brelse>
}
    8000365a:	60e2                	ld	ra,24(sp)
    8000365c:	6442                	ld	s0,16(sp)
    8000365e:	64a2                	ld	s1,8(sp)
    80003660:	6902                	ld	s2,0(sp)
    80003662:	6105                	addi	sp,sp,32
    80003664:	8082                	ret

0000000080003666 <idup>:
{
    80003666:	1101                	addi	sp,sp,-32
    80003668:	ec06                	sd	ra,24(sp)
    8000366a:	e822                	sd	s0,16(sp)
    8000366c:	e426                	sd	s1,8(sp)
    8000366e:	1000                	addi	s0,sp,32
    80003670:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    80003672:	00017517          	auipc	a0,0x17
    80003676:	54e50513          	addi	a0,a0,1358 # 8001abc0 <icache>
    8000367a:	ffffd097          	auipc	ra,0xffffd
    8000367e:	548080e7          	jalr	1352(ra) # 80000bc2 <acquire>
  ip->ref++;
    80003682:	449c                	lw	a5,8(s1)
    80003684:	2785                	addiw	a5,a5,1
    80003686:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    80003688:	00017517          	auipc	a0,0x17
    8000368c:	53850513          	addi	a0,a0,1336 # 8001abc0 <icache>
    80003690:	ffffd097          	auipc	ra,0xffffd
    80003694:	5e6080e7          	jalr	1510(ra) # 80000c76 <release>
}
    80003698:	8526                	mv	a0,s1
    8000369a:	60e2                	ld	ra,24(sp)
    8000369c:	6442                	ld	s0,16(sp)
    8000369e:	64a2                	ld	s1,8(sp)
    800036a0:	6105                	addi	sp,sp,32
    800036a2:	8082                	ret

00000000800036a4 <ilock>:
{
    800036a4:	1101                	addi	sp,sp,-32
    800036a6:	ec06                	sd	ra,24(sp)
    800036a8:	e822                	sd	s0,16(sp)
    800036aa:	e426                	sd	s1,8(sp)
    800036ac:	e04a                	sd	s2,0(sp)
    800036ae:	1000                	addi	s0,sp,32
  if(ip == 0 || ip->ref < 1)
    800036b0:	c115                	beqz	a0,800036d4 <ilock+0x30>
    800036b2:	84aa                	mv	s1,a0
    800036b4:	451c                	lw	a5,8(a0)
    800036b6:	00f05f63          	blez	a5,800036d4 <ilock+0x30>
  acquiresleep(&ip->lock);
    800036ba:	0541                	addi	a0,a0,16
    800036bc:	00001097          	auipc	ra,0x1
    800036c0:	dce080e7          	jalr	-562(ra) # 8000448a <acquiresleep>
  if(ip->valid == 0){
    800036c4:	40bc                	lw	a5,64(s1)
    800036c6:	cf99                	beqz	a5,800036e4 <ilock+0x40>
}
    800036c8:	60e2                	ld	ra,24(sp)
    800036ca:	6442                	ld	s0,16(sp)
    800036cc:	64a2                	ld	s1,8(sp)
    800036ce:	6902                	ld	s2,0(sp)
    800036d0:	6105                	addi	sp,sp,32
    800036d2:	8082                	ret
    panic("ilock");
    800036d4:	00005517          	auipc	a0,0x5
    800036d8:	ed450513          	addi	a0,a0,-300 # 800085a8 <syscalls+0x188>
    800036dc:	ffffd097          	auipc	ra,0xffffd
    800036e0:	e50080e7          	jalr	-432(ra) # 8000052c <panic>
    bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    800036e4:	40dc                	lw	a5,4(s1)
    800036e6:	0047d79b          	srliw	a5,a5,0x4
    800036ea:	00017597          	auipc	a1,0x17
    800036ee:	4ce5a583          	lw	a1,1230(a1) # 8001abb8 <sb+0x18>
    800036f2:	9dbd                	addw	a1,a1,a5
    800036f4:	4088                	lw	a0,0(s1)
    800036f6:	fffff097          	auipc	ra,0xfffff
    800036fa:	6e4080e7          	jalr	1764(ra) # 80002dda <bread>
    800036fe:	892a                	mv	s2,a0
    dip = (struct dinode*)bp->data + ip->inum%IPB;
    80003700:	05850593          	addi	a1,a0,88
    80003704:	40dc                	lw	a5,4(s1)
    80003706:	8bbd                	andi	a5,a5,15
    80003708:	079a                	slli	a5,a5,0x6
    8000370a:	95be                	add	a1,a1,a5
    ip->type = dip->type;
    8000370c:	00059783          	lh	a5,0(a1)
    80003710:	04f49223          	sh	a5,68(s1)
    ip->major = dip->major;
    80003714:	00259783          	lh	a5,2(a1)
    80003718:	04f49323          	sh	a5,70(s1)
    ip->minor = dip->minor;
    8000371c:	00459783          	lh	a5,4(a1)
    80003720:	04f49423          	sh	a5,72(s1)
    ip->nlink = dip->nlink;
    80003724:	00659783          	lh	a5,6(a1)
    80003728:	04f49523          	sh	a5,74(s1)
    ip->size = dip->size;
    8000372c:	459c                	lw	a5,8(a1)
    8000372e:	c4fc                	sw	a5,76(s1)
    memmove(ip->addrs, dip->addrs, sizeof(ip->addrs));
    80003730:	03400613          	li	a2,52
    80003734:	05b1                	addi	a1,a1,12
    80003736:	05048513          	addi	a0,s1,80
    8000373a:	ffffd097          	auipc	ra,0xffffd
    8000373e:	5e0080e7          	jalr	1504(ra) # 80000d1a <memmove>
    brelse(bp);
    80003742:	854a                	mv	a0,s2
    80003744:	fffff097          	auipc	ra,0xfffff
    80003748:	7c6080e7          	jalr	1990(ra) # 80002f0a <brelse>
    ip->valid = 1;
    8000374c:	4785                	li	a5,1
    8000374e:	c0bc                	sw	a5,64(s1)
    if(ip->type == 0)
    80003750:	04449783          	lh	a5,68(s1)
    80003754:	fbb5                	bnez	a5,800036c8 <ilock+0x24>
      panic("ilock: no type");
    80003756:	00005517          	auipc	a0,0x5
    8000375a:	e5a50513          	addi	a0,a0,-422 # 800085b0 <syscalls+0x190>
    8000375e:	ffffd097          	auipc	ra,0xffffd
    80003762:	dce080e7          	jalr	-562(ra) # 8000052c <panic>

0000000080003766 <iunlock>:
{
    80003766:	1101                	addi	sp,sp,-32
    80003768:	ec06                	sd	ra,24(sp)
    8000376a:	e822                	sd	s0,16(sp)
    8000376c:	e426                	sd	s1,8(sp)
    8000376e:	e04a                	sd	s2,0(sp)
    80003770:	1000                	addi	s0,sp,32
  if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1)
    80003772:	c905                	beqz	a0,800037a2 <iunlock+0x3c>
    80003774:	84aa                	mv	s1,a0
    80003776:	01050913          	addi	s2,a0,16
    8000377a:	854a                	mv	a0,s2
    8000377c:	00001097          	auipc	ra,0x1
    80003780:	da8080e7          	jalr	-600(ra) # 80004524 <holdingsleep>
    80003784:	cd19                	beqz	a0,800037a2 <iunlock+0x3c>
    80003786:	449c                	lw	a5,8(s1)
    80003788:	00f05d63          	blez	a5,800037a2 <iunlock+0x3c>
  releasesleep(&ip->lock);
    8000378c:	854a                	mv	a0,s2
    8000378e:	00001097          	auipc	ra,0x1
    80003792:	d52080e7          	jalr	-686(ra) # 800044e0 <releasesleep>
}
    80003796:	60e2                	ld	ra,24(sp)
    80003798:	6442                	ld	s0,16(sp)
    8000379a:	64a2                	ld	s1,8(sp)
    8000379c:	6902                	ld	s2,0(sp)
    8000379e:	6105                	addi	sp,sp,32
    800037a0:	8082                	ret
    panic("iunlock");
    800037a2:	00005517          	auipc	a0,0x5
    800037a6:	e1e50513          	addi	a0,a0,-482 # 800085c0 <syscalls+0x1a0>
    800037aa:	ffffd097          	auipc	ra,0xffffd
    800037ae:	d82080e7          	jalr	-638(ra) # 8000052c <panic>

00000000800037b2 <itrunc>:

// Truncate inode (discard contents).
// Caller must hold ip->lock.
void
itrunc(struct inode *ip)
{
    800037b2:	715d                	addi	sp,sp,-80
    800037b4:	e486                	sd	ra,72(sp)
    800037b6:	e0a2                	sd	s0,64(sp)
    800037b8:	fc26                	sd	s1,56(sp)
    800037ba:	f84a                	sd	s2,48(sp)
    800037bc:	f44e                	sd	s3,40(sp)
    800037be:	f052                	sd	s4,32(sp)
    800037c0:	ec56                	sd	s5,24(sp)
    800037c2:	e85a                	sd	s6,16(sp)
    800037c4:	e45e                	sd	s7,8(sp)
    800037c6:	e062                	sd	s8,0(sp)
    800037c8:	0880                	addi	s0,sp,80
    800037ca:	89aa                	mv	s3,a0
  int i, j;
  struct buf *bp;
  uint *a;

  for(i = 0; i < NDIRECT; i++){
    800037cc:	05050493          	addi	s1,a0,80
    800037d0:	07c50913          	addi	s2,a0,124
    800037d4:	a021                	j	800037dc <itrunc+0x2a>
    800037d6:	0491                	addi	s1,s1,4
    800037d8:	01248d63          	beq	s1,s2,800037f2 <itrunc+0x40>
    if(ip->addrs[i]){
    800037dc:	408c                	lw	a1,0(s1)
    800037de:	dde5                	beqz	a1,800037d6 <itrunc+0x24>
      bfree(ip->dev, ip->addrs[i]);
    800037e0:	0009a503          	lw	a0,0(s3)
    800037e4:	00000097          	auipc	ra,0x0
    800037e8:	83c080e7          	jalr	-1988(ra) # 80003020 <bfree>
      ip->addrs[i] = 0;
    800037ec:	0004a023          	sw	zero,0(s1)
    800037f0:	b7dd                	j	800037d6 <itrunc+0x24>
    }
  }

  if(ip->addrs[NDIRECT]){
    800037f2:	07c9a583          	lw	a1,124(s3)
    800037f6:	e59d                	bnez	a1,80003824 <itrunc+0x72>
    bfree(ip->dev, ip->addrs[NDIRECT]);
    ip->addrs[NDIRECT] = 0;
  }

  // 二级间接索引是否有效
  if(ip->addrs[NDIRECT+1]){
    800037f8:	0809a583          	lw	a1,128(s3)
    800037fc:	eda5                	bnez	a1,80003874 <itrunc+0xc2>
    brelse(bp);
    bfree(ip->dev, ip->addrs[NDIRECT + 1]);
    ip->addrs[NDIRECT + 1] = 0;
  }

  ip->size = 0;
    800037fe:	0409a623          	sw	zero,76(s3)
  iupdate(ip);
    80003802:	854e                	mv	a0,s3
    80003804:	00000097          	auipc	ra,0x0
    80003808:	dd4080e7          	jalr	-556(ra) # 800035d8 <iupdate>
}
    8000380c:	60a6                	ld	ra,72(sp)
    8000380e:	6406                	ld	s0,64(sp)
    80003810:	74e2                	ld	s1,56(sp)
    80003812:	7942                	ld	s2,48(sp)
    80003814:	79a2                	ld	s3,40(sp)
    80003816:	7a02                	ld	s4,32(sp)
    80003818:	6ae2                	ld	s5,24(sp)
    8000381a:	6b42                	ld	s6,16(sp)
    8000381c:	6ba2                	ld	s7,8(sp)
    8000381e:	6c02                	ld	s8,0(sp)
    80003820:	6161                	addi	sp,sp,80
    80003822:	8082                	ret
    bp = bread(ip->dev, ip->addrs[NDIRECT]);
    80003824:	0009a503          	lw	a0,0(s3)
    80003828:	fffff097          	auipc	ra,0xfffff
    8000382c:	5b2080e7          	jalr	1458(ra) # 80002dda <bread>
    80003830:	8a2a                	mv	s4,a0
    for(j = 0; j < NINDIRECT; j++){
    80003832:	05850493          	addi	s1,a0,88
    80003836:	45850913          	addi	s2,a0,1112
    8000383a:	a021                	j	80003842 <itrunc+0x90>
    8000383c:	0491                	addi	s1,s1,4
    8000383e:	01248b63          	beq	s1,s2,80003854 <itrunc+0xa2>
      if(a[j])
    80003842:	408c                	lw	a1,0(s1)
    80003844:	dde5                	beqz	a1,8000383c <itrunc+0x8a>
        bfree(ip->dev, a[j]);
    80003846:	0009a503          	lw	a0,0(s3)
    8000384a:	fffff097          	auipc	ra,0xfffff
    8000384e:	7d6080e7          	jalr	2006(ra) # 80003020 <bfree>
    80003852:	b7ed                	j	8000383c <itrunc+0x8a>
    brelse(bp);
    80003854:	8552                	mv	a0,s4
    80003856:	fffff097          	auipc	ra,0xfffff
    8000385a:	6b4080e7          	jalr	1716(ra) # 80002f0a <brelse>
    bfree(ip->dev, ip->addrs[NDIRECT]);
    8000385e:	07c9a583          	lw	a1,124(s3)
    80003862:	0009a503          	lw	a0,0(s3)
    80003866:	fffff097          	auipc	ra,0xfffff
    8000386a:	7ba080e7          	jalr	1978(ra) # 80003020 <bfree>
    ip->addrs[NDIRECT] = 0;
    8000386e:	0609ae23          	sw	zero,124(s3)
    80003872:	b759                	j	800037f8 <itrunc+0x46>
    bp = bread(ip->dev, ip->addrs[NDIRECT + 1]);
    80003874:	0009a503          	lw	a0,0(s3)
    80003878:	fffff097          	auipc	ra,0xfffff
    8000387c:	562080e7          	jalr	1378(ra) # 80002dda <bread>
    80003880:	8c2a                	mv	s8,a0
    for(j = 0; j < NINDIRECT; j++){
    80003882:	05850a13          	addi	s4,a0,88
    80003886:	45850b13          	addi	s6,a0,1112
    8000388a:	a82d                	j	800038c4 <itrunc+0x112>
        for(k = 0; k < NINDIRECT; k++){
    8000388c:	0491                	addi	s1,s1,4
    8000388e:	00990b63          	beq	s2,s1,800038a4 <itrunc+0xf2>
          if(a2[k])
    80003892:	408c                	lw	a1,0(s1)
    80003894:	dde5                	beqz	a1,8000388c <itrunc+0xda>
            bfree(ip->dev, a2[k]);
    80003896:	0009a503          	lw	a0,0(s3)
    8000389a:	fffff097          	auipc	ra,0xfffff
    8000389e:	786080e7          	jalr	1926(ra) # 80003020 <bfree>
    800038a2:	b7ed                	j	8000388c <itrunc+0xda>
        brelse(bp2);
    800038a4:	855e                	mv	a0,s7
    800038a6:	fffff097          	auipc	ra,0xfffff
    800038aa:	664080e7          	jalr	1636(ra) # 80002f0a <brelse>
        bfree(ip->dev, a[j]);
    800038ae:	000aa583          	lw	a1,0(s5)
    800038b2:	0009a503          	lw	a0,0(s3)
    800038b6:	fffff097          	auipc	ra,0xfffff
    800038ba:	76a080e7          	jalr	1898(ra) # 80003020 <bfree>
    for(j = 0; j < NINDIRECT; j++){
    800038be:	0a11                	addi	s4,s4,4
    800038c0:	034b0263          	beq	s6,s4,800038e4 <itrunc+0x132>
      if(a[j]){
    800038c4:	8ad2                	mv	s5,s4
    800038c6:	000a2583          	lw	a1,0(s4)
    800038ca:	d9f5                	beqz	a1,800038be <itrunc+0x10c>
        struct buf *bp2 = bread(ip->dev, a[j]);
    800038cc:	0009a503          	lw	a0,0(s3)
    800038d0:	fffff097          	auipc	ra,0xfffff
    800038d4:	50a080e7          	jalr	1290(ra) # 80002dda <bread>
    800038d8:	8baa                	mv	s7,a0
        for(k = 0; k < NINDIRECT; k++){
    800038da:	05850493          	addi	s1,a0,88
    800038de:	45850913          	addi	s2,a0,1112
    800038e2:	bf45                	j	80003892 <itrunc+0xe0>
    brelse(bp);
    800038e4:	8562                	mv	a0,s8
    800038e6:	fffff097          	auipc	ra,0xfffff
    800038ea:	624080e7          	jalr	1572(ra) # 80002f0a <brelse>
    bfree(ip->dev, ip->addrs[NDIRECT + 1]);
    800038ee:	0809a583          	lw	a1,128(s3)
    800038f2:	0009a503          	lw	a0,0(s3)
    800038f6:	fffff097          	auipc	ra,0xfffff
    800038fa:	72a080e7          	jalr	1834(ra) # 80003020 <bfree>
    ip->addrs[NDIRECT + 1] = 0;
    800038fe:	0809a023          	sw	zero,128(s3)
    80003902:	bdf5                	j	800037fe <itrunc+0x4c>

0000000080003904 <iput>:
{
    80003904:	1101                	addi	sp,sp,-32
    80003906:	ec06                	sd	ra,24(sp)
    80003908:	e822                	sd	s0,16(sp)
    8000390a:	e426                	sd	s1,8(sp)
    8000390c:	e04a                	sd	s2,0(sp)
    8000390e:	1000                	addi	s0,sp,32
    80003910:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    80003912:	00017517          	auipc	a0,0x17
    80003916:	2ae50513          	addi	a0,a0,686 # 8001abc0 <icache>
    8000391a:	ffffd097          	auipc	ra,0xffffd
    8000391e:	2a8080e7          	jalr	680(ra) # 80000bc2 <acquire>
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    80003922:	4498                	lw	a4,8(s1)
    80003924:	4785                	li	a5,1
    80003926:	02f70363          	beq	a4,a5,8000394c <iput+0x48>
  ip->ref--;
    8000392a:	449c                	lw	a5,8(s1)
    8000392c:	37fd                	addiw	a5,a5,-1
    8000392e:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    80003930:	00017517          	auipc	a0,0x17
    80003934:	29050513          	addi	a0,a0,656 # 8001abc0 <icache>
    80003938:	ffffd097          	auipc	ra,0xffffd
    8000393c:	33e080e7          	jalr	830(ra) # 80000c76 <release>
}
    80003940:	60e2                	ld	ra,24(sp)
    80003942:	6442                	ld	s0,16(sp)
    80003944:	64a2                	ld	s1,8(sp)
    80003946:	6902                	ld	s2,0(sp)
    80003948:	6105                	addi	sp,sp,32
    8000394a:	8082                	ret
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    8000394c:	40bc                	lw	a5,64(s1)
    8000394e:	dff1                	beqz	a5,8000392a <iput+0x26>
    80003950:	04a49783          	lh	a5,74(s1)
    80003954:	fbf9                	bnez	a5,8000392a <iput+0x26>
    acquiresleep(&ip->lock);
    80003956:	01048913          	addi	s2,s1,16
    8000395a:	854a                	mv	a0,s2
    8000395c:	00001097          	auipc	ra,0x1
    80003960:	b2e080e7          	jalr	-1234(ra) # 8000448a <acquiresleep>
    release(&icache.lock);
    80003964:	00017517          	auipc	a0,0x17
    80003968:	25c50513          	addi	a0,a0,604 # 8001abc0 <icache>
    8000396c:	ffffd097          	auipc	ra,0xffffd
    80003970:	30a080e7          	jalr	778(ra) # 80000c76 <release>
    itrunc(ip);
    80003974:	8526                	mv	a0,s1
    80003976:	00000097          	auipc	ra,0x0
    8000397a:	e3c080e7          	jalr	-452(ra) # 800037b2 <itrunc>
    ip->type = 0;
    8000397e:	04049223          	sh	zero,68(s1)
    iupdate(ip);
    80003982:	8526                	mv	a0,s1
    80003984:	00000097          	auipc	ra,0x0
    80003988:	c54080e7          	jalr	-940(ra) # 800035d8 <iupdate>
    ip->valid = 0;
    8000398c:	0404a023          	sw	zero,64(s1)
    releasesleep(&ip->lock);
    80003990:	854a                	mv	a0,s2
    80003992:	00001097          	auipc	ra,0x1
    80003996:	b4e080e7          	jalr	-1202(ra) # 800044e0 <releasesleep>
    acquire(&icache.lock);
    8000399a:	00017517          	auipc	a0,0x17
    8000399e:	22650513          	addi	a0,a0,550 # 8001abc0 <icache>
    800039a2:	ffffd097          	auipc	ra,0xffffd
    800039a6:	220080e7          	jalr	544(ra) # 80000bc2 <acquire>
    800039aa:	b741                	j	8000392a <iput+0x26>

00000000800039ac <iunlockput>:
{
    800039ac:	1101                	addi	sp,sp,-32
    800039ae:	ec06                	sd	ra,24(sp)
    800039b0:	e822                	sd	s0,16(sp)
    800039b2:	e426                	sd	s1,8(sp)
    800039b4:	1000                	addi	s0,sp,32
    800039b6:	84aa                	mv	s1,a0
  iunlock(ip);
    800039b8:	00000097          	auipc	ra,0x0
    800039bc:	dae080e7          	jalr	-594(ra) # 80003766 <iunlock>
  iput(ip);
    800039c0:	8526                	mv	a0,s1
    800039c2:	00000097          	auipc	ra,0x0
    800039c6:	f42080e7          	jalr	-190(ra) # 80003904 <iput>
}
    800039ca:	60e2                	ld	ra,24(sp)
    800039cc:	6442                	ld	s0,16(sp)
    800039ce:	64a2                	ld	s1,8(sp)
    800039d0:	6105                	addi	sp,sp,32
    800039d2:	8082                	ret

00000000800039d4 <stati>:

// Copy stat information from inode.
// Caller must hold ip->lock.
void
stati(struct inode *ip, struct stat *st)
{
    800039d4:	1141                	addi	sp,sp,-16
    800039d6:	e422                	sd	s0,8(sp)
    800039d8:	0800                	addi	s0,sp,16
  st->dev = ip->dev;
    800039da:	411c                	lw	a5,0(a0)
    800039dc:	c19c                	sw	a5,0(a1)
  st->ino = ip->inum;
    800039de:	415c                	lw	a5,4(a0)
    800039e0:	c1dc                	sw	a5,4(a1)
  st->type = ip->type;
    800039e2:	04451783          	lh	a5,68(a0)
    800039e6:	00f59423          	sh	a5,8(a1)
  st->nlink = ip->nlink;
    800039ea:	04a51783          	lh	a5,74(a0)
    800039ee:	00f59523          	sh	a5,10(a1)
  st->size = ip->size;
    800039f2:	04c56783          	lwu	a5,76(a0)
    800039f6:	e99c                	sd	a5,16(a1)
}
    800039f8:	6422                	ld	s0,8(sp)
    800039fa:	0141                	addi	sp,sp,16
    800039fc:	8082                	ret

00000000800039fe <readi>:
readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    800039fe:	457c                	lw	a5,76(a0)
    80003a00:	0ed7e963          	bltu	a5,a3,80003af2 <readi+0xf4>
{
    80003a04:	7159                	addi	sp,sp,-112
    80003a06:	f486                	sd	ra,104(sp)
    80003a08:	f0a2                	sd	s0,96(sp)
    80003a0a:	eca6                	sd	s1,88(sp)
    80003a0c:	e8ca                	sd	s2,80(sp)
    80003a0e:	e4ce                	sd	s3,72(sp)
    80003a10:	e0d2                	sd	s4,64(sp)
    80003a12:	fc56                	sd	s5,56(sp)
    80003a14:	f85a                	sd	s6,48(sp)
    80003a16:	f45e                	sd	s7,40(sp)
    80003a18:	f062                	sd	s8,32(sp)
    80003a1a:	ec66                	sd	s9,24(sp)
    80003a1c:	e86a                	sd	s10,16(sp)
    80003a1e:	e46e                	sd	s11,8(sp)
    80003a20:	1880                	addi	s0,sp,112
    80003a22:	8baa                	mv	s7,a0
    80003a24:	8c2e                	mv	s8,a1
    80003a26:	8ab2                	mv	s5,a2
    80003a28:	84b6                	mv	s1,a3
    80003a2a:	8b3a                	mv	s6,a4
  if(off > ip->size || off + n < off)
    80003a2c:	9f35                	addw	a4,a4,a3
    return 0;
    80003a2e:	4501                	li	a0,0
  if(off > ip->size || off + n < off)
    80003a30:	0ad76063          	bltu	a4,a3,80003ad0 <readi+0xd2>
  if(off + n > ip->size)
    80003a34:	00e7f463          	bgeu	a5,a4,80003a3c <readi+0x3e>
    n = ip->size - off;
    80003a38:	40d78b3b          	subw	s6,a5,a3

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003a3c:	0a0b0963          	beqz	s6,80003aee <readi+0xf0>
    80003a40:	4981                	li	s3,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    80003a42:	40000d13          	li	s10,1024
    if(either_copyout(user_dst, dst, bp->data + (off % BSIZE), m) == -1) {
    80003a46:	5cfd                	li	s9,-1
    80003a48:	a82d                	j	80003a82 <readi+0x84>
    80003a4a:	020a1d93          	slli	s11,s4,0x20
    80003a4e:	020ddd93          	srli	s11,s11,0x20
    80003a52:	05890613          	addi	a2,s2,88
    80003a56:	86ee                	mv	a3,s11
    80003a58:	963a                	add	a2,a2,a4
    80003a5a:	85d6                	mv	a1,s5
    80003a5c:	8562                	mv	a0,s8
    80003a5e:	fffff097          	auipc	ra,0xfffff
    80003a62:	9be080e7          	jalr	-1602(ra) # 8000241c <either_copyout>
    80003a66:	05950d63          	beq	a0,s9,80003ac0 <readi+0xc2>
      brelse(bp);
      tot = -1;
      break;
    }
    brelse(bp);
    80003a6a:	854a                	mv	a0,s2
    80003a6c:	fffff097          	auipc	ra,0xfffff
    80003a70:	49e080e7          	jalr	1182(ra) # 80002f0a <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003a74:	013a09bb          	addw	s3,s4,s3
    80003a78:	009a04bb          	addw	s1,s4,s1
    80003a7c:	9aee                	add	s5,s5,s11
    80003a7e:	0569f763          	bgeu	s3,s6,80003acc <readi+0xce>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    80003a82:	000ba903          	lw	s2,0(s7)
    80003a86:	00a4d59b          	srliw	a1,s1,0xa
    80003a8a:	855e                	mv	a0,s7
    80003a8c:	fffff097          	auipc	ra,0xfffff
    80003a90:	73e080e7          	jalr	1854(ra) # 800031ca <bmap>
    80003a94:	0005059b          	sext.w	a1,a0
    80003a98:	854a                	mv	a0,s2
    80003a9a:	fffff097          	auipc	ra,0xfffff
    80003a9e:	340080e7          	jalr	832(ra) # 80002dda <bread>
    80003aa2:	892a                	mv	s2,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003aa4:	3ff4f713          	andi	a4,s1,1023
    80003aa8:	40ed07bb          	subw	a5,s10,a4
    80003aac:	413b06bb          	subw	a3,s6,s3
    80003ab0:	8a3e                	mv	s4,a5
    80003ab2:	2781                	sext.w	a5,a5
    80003ab4:	0006861b          	sext.w	a2,a3
    80003ab8:	f8f679e3          	bgeu	a2,a5,80003a4a <readi+0x4c>
    80003abc:	8a36                	mv	s4,a3
    80003abe:	b771                	j	80003a4a <readi+0x4c>
      brelse(bp);
    80003ac0:	854a                	mv	a0,s2
    80003ac2:	fffff097          	auipc	ra,0xfffff
    80003ac6:	448080e7          	jalr	1096(ra) # 80002f0a <brelse>
      tot = -1;
    80003aca:	59fd                	li	s3,-1
  }
  return tot;
    80003acc:	0009851b          	sext.w	a0,s3
}
    80003ad0:	70a6                	ld	ra,104(sp)
    80003ad2:	7406                	ld	s0,96(sp)
    80003ad4:	64e6                	ld	s1,88(sp)
    80003ad6:	6946                	ld	s2,80(sp)
    80003ad8:	69a6                	ld	s3,72(sp)
    80003ada:	6a06                	ld	s4,64(sp)
    80003adc:	7ae2                	ld	s5,56(sp)
    80003ade:	7b42                	ld	s6,48(sp)
    80003ae0:	7ba2                	ld	s7,40(sp)
    80003ae2:	7c02                	ld	s8,32(sp)
    80003ae4:	6ce2                	ld	s9,24(sp)
    80003ae6:	6d42                	ld	s10,16(sp)
    80003ae8:	6da2                	ld	s11,8(sp)
    80003aea:	6165                	addi	sp,sp,112
    80003aec:	8082                	ret
  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003aee:	89da                	mv	s3,s6
    80003af0:	bff1                	j	80003acc <readi+0xce>
    return 0;
    80003af2:	4501                	li	a0,0
}
    80003af4:	8082                	ret

0000000080003af6 <writei>:
writei(struct inode *ip, int user_src, uint64 src, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    80003af6:	457c                	lw	a5,76(a0)
    80003af8:	10d7e963          	bltu	a5,a3,80003c0a <writei+0x114>
{
    80003afc:	7159                	addi	sp,sp,-112
    80003afe:	f486                	sd	ra,104(sp)
    80003b00:	f0a2                	sd	s0,96(sp)
    80003b02:	eca6                	sd	s1,88(sp)
    80003b04:	e8ca                	sd	s2,80(sp)
    80003b06:	e4ce                	sd	s3,72(sp)
    80003b08:	e0d2                	sd	s4,64(sp)
    80003b0a:	fc56                	sd	s5,56(sp)
    80003b0c:	f85a                	sd	s6,48(sp)
    80003b0e:	f45e                	sd	s7,40(sp)
    80003b10:	f062                	sd	s8,32(sp)
    80003b12:	ec66                	sd	s9,24(sp)
    80003b14:	e86a                	sd	s10,16(sp)
    80003b16:	e46e                	sd	s11,8(sp)
    80003b18:	1880                	addi	s0,sp,112
    80003b1a:	8b2a                	mv	s6,a0
    80003b1c:	8c2e                	mv	s8,a1
    80003b1e:	8ab2                	mv	s5,a2
    80003b20:	8936                	mv	s2,a3
    80003b22:	8bba                	mv	s7,a4
  if(off > ip->size || off + n < off)
    80003b24:	9f35                	addw	a4,a4,a3
    80003b26:	0ed76463          	bltu	a4,a3,80003c0e <writei+0x118>
    return -1;
  if(off + n > MAXFILE*BSIZE)
    80003b2a:	040437b7          	lui	a5,0x4043
    80003b2e:	c0078793          	addi	a5,a5,-1024 # 4042c00 <_entry-0x7bfbd400>
    80003b32:	0ee7e063          	bltu	a5,a4,80003c12 <writei+0x11c>
    return -1;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003b36:	0c0b8863          	beqz	s7,80003c06 <writei+0x110>
    80003b3a:	4a01                	li	s4,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    80003b3c:	40000d13          	li	s10,1024
    if(either_copyin(bp->data + (off % BSIZE), user_src, src, m) == -1) {
    80003b40:	5cfd                	li	s9,-1
    80003b42:	a091                	j	80003b86 <writei+0x90>
    80003b44:	02099d93          	slli	s11,s3,0x20
    80003b48:	020ddd93          	srli	s11,s11,0x20
    80003b4c:	05848513          	addi	a0,s1,88
    80003b50:	86ee                	mv	a3,s11
    80003b52:	8656                	mv	a2,s5
    80003b54:	85e2                	mv	a1,s8
    80003b56:	953a                	add	a0,a0,a4
    80003b58:	fffff097          	auipc	ra,0xfffff
    80003b5c:	91a080e7          	jalr	-1766(ra) # 80002472 <either_copyin>
    80003b60:	07950263          	beq	a0,s9,80003bc4 <writei+0xce>
      brelse(bp);
      break;
    }
    log_write(bp);
    80003b64:	8526                	mv	a0,s1
    80003b66:	00000097          	auipc	ra,0x0
    80003b6a:	7fe080e7          	jalr	2046(ra) # 80004364 <log_write>
    brelse(bp);
    80003b6e:	8526                	mv	a0,s1
    80003b70:	fffff097          	auipc	ra,0xfffff
    80003b74:	39a080e7          	jalr	922(ra) # 80002f0a <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003b78:	01498a3b          	addw	s4,s3,s4
    80003b7c:	0129893b          	addw	s2,s3,s2
    80003b80:	9aee                	add	s5,s5,s11
    80003b82:	057a7663          	bgeu	s4,s7,80003bce <writei+0xd8>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    80003b86:	000b2483          	lw	s1,0(s6)
    80003b8a:	00a9559b          	srliw	a1,s2,0xa
    80003b8e:	855a                	mv	a0,s6
    80003b90:	fffff097          	auipc	ra,0xfffff
    80003b94:	63a080e7          	jalr	1594(ra) # 800031ca <bmap>
    80003b98:	0005059b          	sext.w	a1,a0
    80003b9c:	8526                	mv	a0,s1
    80003b9e:	fffff097          	auipc	ra,0xfffff
    80003ba2:	23c080e7          	jalr	572(ra) # 80002dda <bread>
    80003ba6:	84aa                	mv	s1,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003ba8:	3ff97713          	andi	a4,s2,1023
    80003bac:	40ed07bb          	subw	a5,s10,a4
    80003bb0:	414b86bb          	subw	a3,s7,s4
    80003bb4:	89be                	mv	s3,a5
    80003bb6:	2781                	sext.w	a5,a5
    80003bb8:	0006861b          	sext.w	a2,a3
    80003bbc:	f8f674e3          	bgeu	a2,a5,80003b44 <writei+0x4e>
    80003bc0:	89b6                	mv	s3,a3
    80003bc2:	b749                	j	80003b44 <writei+0x4e>
      brelse(bp);
    80003bc4:	8526                	mv	a0,s1
    80003bc6:	fffff097          	auipc	ra,0xfffff
    80003bca:	344080e7          	jalr	836(ra) # 80002f0a <brelse>
  }

  if(off > ip->size)
    80003bce:	04cb2783          	lw	a5,76(s6)
    80003bd2:	0127f463          	bgeu	a5,s2,80003bda <writei+0xe4>
    ip->size = off;
    80003bd6:	052b2623          	sw	s2,76(s6)

  // write the i-node back to disk even if the size didn't change
  // because the loop above might have called bmap() and added a new
  // block to ip->addrs[].
  iupdate(ip);
    80003bda:	855a                	mv	a0,s6
    80003bdc:	00000097          	auipc	ra,0x0
    80003be0:	9fc080e7          	jalr	-1540(ra) # 800035d8 <iupdate>

  return tot;
    80003be4:	000a051b          	sext.w	a0,s4
}
    80003be8:	70a6                	ld	ra,104(sp)
    80003bea:	7406                	ld	s0,96(sp)
    80003bec:	64e6                	ld	s1,88(sp)
    80003bee:	6946                	ld	s2,80(sp)
    80003bf0:	69a6                	ld	s3,72(sp)
    80003bf2:	6a06                	ld	s4,64(sp)
    80003bf4:	7ae2                	ld	s5,56(sp)
    80003bf6:	7b42                	ld	s6,48(sp)
    80003bf8:	7ba2                	ld	s7,40(sp)
    80003bfa:	7c02                	ld	s8,32(sp)
    80003bfc:	6ce2                	ld	s9,24(sp)
    80003bfe:	6d42                	ld	s10,16(sp)
    80003c00:	6da2                	ld	s11,8(sp)
    80003c02:	6165                	addi	sp,sp,112
    80003c04:	8082                	ret
  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003c06:	8a5e                	mv	s4,s7
    80003c08:	bfc9                	j	80003bda <writei+0xe4>
    return -1;
    80003c0a:	557d                	li	a0,-1
}
    80003c0c:	8082                	ret
    return -1;
    80003c0e:	557d                	li	a0,-1
    80003c10:	bfe1                	j	80003be8 <writei+0xf2>
    return -1;
    80003c12:	557d                	li	a0,-1
    80003c14:	bfd1                	j	80003be8 <writei+0xf2>

0000000080003c16 <namecmp>:

// Directories

int
namecmp(const char *s, const char *t)
{
    80003c16:	1141                	addi	sp,sp,-16
    80003c18:	e406                	sd	ra,8(sp)
    80003c1a:	e022                	sd	s0,0(sp)
    80003c1c:	0800                	addi	s0,sp,16
  return strncmp(s, t, DIRSIZ);
    80003c1e:	4639                	li	a2,14
    80003c20:	ffffd097          	auipc	ra,0xffffd
    80003c24:	176080e7          	jalr	374(ra) # 80000d96 <strncmp>
}
    80003c28:	60a2                	ld	ra,8(sp)
    80003c2a:	6402                	ld	s0,0(sp)
    80003c2c:	0141                	addi	sp,sp,16
    80003c2e:	8082                	ret

0000000080003c30 <rbtn>:

// 系统查找ip->dev所在的设备上的块号为block的块中存储的结构体
int
rbtn(struct inode *ip, int user_dst, uint64 dst, int n, int block)
{
    80003c30:	7179                	addi	sp,sp,-48
    80003c32:	f406                	sd	ra,40(sp)
    80003c34:	f022                	sd	s0,32(sp)
    80003c36:	ec26                	sd	s1,24(sp)
    80003c38:	e84a                	sd	s2,16(sp)
    80003c3a:	e44e                	sd	s3,8(sp)
    80003c3c:	1800                	addi	s0,sp,48
    80003c3e:	84ae                	mv	s1,a1
    80003c40:	89b2                	mv	s3,a2
  struct buf *bp;
  bp = bread(ip->dev, block);
    80003c42:	85ba                	mv	a1,a4
    80003c44:	4108                	lw	a0,0(a0)
    80003c46:	fffff097          	auipc	ra,0xfffff
    80003c4a:	194080e7          	jalr	404(ra) # 80002dda <bread>
    80003c4e:	892a                	mv	s2,a0
  if(either_copyout(user_dst, dst, bp->data, sizeof(struct btreenode)) == -1) {
    80003c50:	26c00693          	li	a3,620
    80003c54:	05850613          	addi	a2,a0,88
    80003c58:	85ce                	mv	a1,s3
    80003c5a:	8526                	mv	a0,s1
    80003c5c:	ffffe097          	auipc	ra,0xffffe
    80003c60:	7c0080e7          	jalr	1984(ra) # 8000241c <either_copyout>
    80003c64:	57fd                	li	a5,-1
    80003c66:	02f50163          	beq	a0,a5,80003c88 <rbtn+0x58>
    brelse(bp); // 释放缓冲区
    return -1;  // 设置错误标志
  }
  // 释放缓冲区（注意：在成功复制数据后应立即释放，以避免内存泄漏）
  brelse(bp);
    80003c6a:	854a                	mv	a0,s2
    80003c6c:	fffff097          	auipc	ra,0xfffff
    80003c70:	29e080e7          	jalr	670(ra) # 80002f0a <brelse>
  return sizeof(struct btreenode);
    80003c74:	26c00493          	li	s1,620
}
    80003c78:	8526                	mv	a0,s1
    80003c7a:	70a2                	ld	ra,40(sp)
    80003c7c:	7402                	ld	s0,32(sp)
    80003c7e:	64e2                	ld	s1,24(sp)
    80003c80:	6942                	ld	s2,16(sp)
    80003c82:	69a2                	ld	s3,8(sp)
    80003c84:	6145                	addi	sp,sp,48
    80003c86:	8082                	ret
    80003c88:	84aa                	mv	s1,a0
    brelse(bp); // 释放缓冲区
    80003c8a:	854a                	mv	a0,s2
    80003c8c:	fffff097          	auipc	ra,0xfffff
    80003c90:	27e080e7          	jalr	638(ra) # 80002f0a <brelse>
    return -1;  // 设置错误标志
    80003c94:	b7d5                	j	80003c78 <rbtn+0x48>

0000000080003c96 <dirlookup>:

// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
struct inode*
dirlookup(struct inode *dp, char *name, uint *poff)
{
    80003c96:	7139                	addi	sp,sp,-64
    80003c98:	fc06                	sd	ra,56(sp)
    80003c9a:	f822                	sd	s0,48(sp)
    80003c9c:	f426                	sd	s1,40(sp)
    80003c9e:	f04a                	sd	s2,32(sp)
    80003ca0:	ec4e                	sd	s3,24(sp)
    80003ca2:	e852                	sd	s4,16(sp)
    80003ca4:	0080                	addi	s0,sp,64
  uint off, inum;
  struct dirent de;

  if(dp->type != T_DIR)
    80003ca6:	04451703          	lh	a4,68(a0)
    80003caa:	4785                	li	a5,1
    80003cac:	00f71a63          	bne	a4,a5,80003cc0 <dirlookup+0x2a>
    80003cb0:	892a                	mv	s2,a0
    80003cb2:	89ae                	mv	s3,a1
    80003cb4:	8a32                	mv	s4,a2
    panic("dirlookup not DIR");

  for(off = 0; off < dp->size; off += sizeof(de)){
    80003cb6:	457c                	lw	a5,76(a0)
    80003cb8:	4481                	li	s1,0
      inum = de.inum;
      return iget(dp->dev, inum);
    }
  }

  return 0;
    80003cba:	4501                	li	a0,0
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003cbc:	e79d                	bnez	a5,80003cea <dirlookup+0x54>
    80003cbe:	a8a5                	j	80003d36 <dirlookup+0xa0>
    panic("dirlookup not DIR");
    80003cc0:	00005517          	auipc	a0,0x5
    80003cc4:	90850513          	addi	a0,a0,-1784 # 800085c8 <syscalls+0x1a8>
    80003cc8:	ffffd097          	auipc	ra,0xffffd
    80003ccc:	864080e7          	jalr	-1948(ra) # 8000052c <panic>
      panic("dirlookup read");
    80003cd0:	00005517          	auipc	a0,0x5
    80003cd4:	91050513          	addi	a0,a0,-1776 # 800085e0 <syscalls+0x1c0>
    80003cd8:	ffffd097          	auipc	ra,0xffffd
    80003cdc:	854080e7          	jalr	-1964(ra) # 8000052c <panic>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003ce0:	24c1                	addiw	s1,s1,16
    80003ce2:	04c92783          	lw	a5,76(s2)
    80003ce6:	04f4f763          	bgeu	s1,a5,80003d34 <dirlookup+0x9e>
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003cea:	4741                	li	a4,16
    80003cec:	86a6                	mv	a3,s1
    80003cee:	fc040613          	addi	a2,s0,-64
    80003cf2:	4581                	li	a1,0
    80003cf4:	854a                	mv	a0,s2
    80003cf6:	00000097          	auipc	ra,0x0
    80003cfa:	d08080e7          	jalr	-760(ra) # 800039fe <readi>
    80003cfe:	47c1                	li	a5,16
    80003d00:	fcf518e3          	bne	a0,a5,80003cd0 <dirlookup+0x3a>
    if(de.inum == 0)
    80003d04:	fc045783          	lhu	a5,-64(s0)
    80003d08:	dfe1                	beqz	a5,80003ce0 <dirlookup+0x4a>
    if(namecmp(name, de.name) == 0){
    80003d0a:	fc240593          	addi	a1,s0,-62
    80003d0e:	854e                	mv	a0,s3
    80003d10:	00000097          	auipc	ra,0x0
    80003d14:	f06080e7          	jalr	-250(ra) # 80003c16 <namecmp>
    80003d18:	f561                	bnez	a0,80003ce0 <dirlookup+0x4a>
      if(poff)
    80003d1a:	000a0463          	beqz	s4,80003d22 <dirlookup+0x8c>
        *poff = off;
    80003d1e:	009a2023          	sw	s1,0(s4)
      return iget(dp->dev, inum);
    80003d22:	fc045583          	lhu	a1,-64(s0)
    80003d26:	00092503          	lw	a0,0(s2)
    80003d2a:	fffff097          	auipc	ra,0xfffff
    80003d2e:	644080e7          	jalr	1604(ra) # 8000336e <iget>
    80003d32:	a011                	j	80003d36 <dirlookup+0xa0>
  return 0;
    80003d34:	4501                	li	a0,0
}
    80003d36:	70e2                	ld	ra,56(sp)
    80003d38:	7442                	ld	s0,48(sp)
    80003d3a:	74a2                	ld	s1,40(sp)
    80003d3c:	7902                	ld	s2,32(sp)
    80003d3e:	69e2                	ld	s3,24(sp)
    80003d40:	6a42                	ld	s4,16(sp)
    80003d42:	6121                	addi	sp,sp,64
    80003d44:	8082                	ret

0000000080003d46 <namex>:
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
// Must be called inside a transaction since it calls iput().
static struct inode*
namex(char *path, int nameiparent, char *name)
{
    80003d46:	711d                	addi	sp,sp,-96
    80003d48:	ec86                	sd	ra,88(sp)
    80003d4a:	e8a2                	sd	s0,80(sp)
    80003d4c:	e4a6                	sd	s1,72(sp)
    80003d4e:	e0ca                	sd	s2,64(sp)
    80003d50:	fc4e                	sd	s3,56(sp)
    80003d52:	f852                	sd	s4,48(sp)
    80003d54:	f456                	sd	s5,40(sp)
    80003d56:	f05a                	sd	s6,32(sp)
    80003d58:	ec5e                	sd	s7,24(sp)
    80003d5a:	e862                	sd	s8,16(sp)
    80003d5c:	e466                	sd	s9,8(sp)
    80003d5e:	e06a                	sd	s10,0(sp)
    80003d60:	1080                	addi	s0,sp,96
    80003d62:	84aa                	mv	s1,a0
    80003d64:	8b2e                	mv	s6,a1
    80003d66:	8ab2                	mv	s5,a2
  struct inode *ip, *next;

  if(*path == '/')
    80003d68:	00054703          	lbu	a4,0(a0)
    80003d6c:	02f00793          	li	a5,47
    80003d70:	02f70363          	beq	a4,a5,80003d96 <namex+0x50>
    ip = iget(ROOTDEV, ROOTINO);
  else
    ip = idup(myproc()->cwd);
    80003d74:	ffffe097          	auipc	ra,0xffffe
    80003d78:	c36080e7          	jalr	-970(ra) # 800019aa <myproc>
    80003d7c:	15053503          	ld	a0,336(a0)
    80003d80:	00000097          	auipc	ra,0x0
    80003d84:	8e6080e7          	jalr	-1818(ra) # 80003666 <idup>
    80003d88:	8a2a                	mv	s4,a0
  while(*path == '/')
    80003d8a:	02f00913          	li	s2,47
  if(len >= DIRSIZ)
    80003d8e:	4cb5                	li	s9,13
  len = path - s;
    80003d90:	4b81                	li	s7,0

  while((path = skipelem(path, name)) != 0){
    ilock(ip);
    if(ip->type != T_DIR){
    80003d92:	4c05                	li	s8,1
    80003d94:	a87d                	j	80003e52 <namex+0x10c>
    ip = iget(ROOTDEV, ROOTINO);
    80003d96:	4585                	li	a1,1
    80003d98:	4505                	li	a0,1
    80003d9a:	fffff097          	auipc	ra,0xfffff
    80003d9e:	5d4080e7          	jalr	1492(ra) # 8000336e <iget>
    80003da2:	8a2a                	mv	s4,a0
    80003da4:	b7dd                	j	80003d8a <namex+0x44>
      iunlockput(ip);
    80003da6:	8552                	mv	a0,s4
    80003da8:	00000097          	auipc	ra,0x0
    80003dac:	c04080e7          	jalr	-1020(ra) # 800039ac <iunlockput>
      return 0;
    80003db0:	4a01                	li	s4,0
  if(nameiparent){
    iput(ip);
    return 0;
  }
  return ip;
}
    80003db2:	8552                	mv	a0,s4
    80003db4:	60e6                	ld	ra,88(sp)
    80003db6:	6446                	ld	s0,80(sp)
    80003db8:	64a6                	ld	s1,72(sp)
    80003dba:	6906                	ld	s2,64(sp)
    80003dbc:	79e2                	ld	s3,56(sp)
    80003dbe:	7a42                	ld	s4,48(sp)
    80003dc0:	7aa2                	ld	s5,40(sp)
    80003dc2:	7b02                	ld	s6,32(sp)
    80003dc4:	6be2                	ld	s7,24(sp)
    80003dc6:	6c42                	ld	s8,16(sp)
    80003dc8:	6ca2                	ld	s9,8(sp)
    80003dca:	6d02                	ld	s10,0(sp)
    80003dcc:	6125                	addi	sp,sp,96
    80003dce:	8082                	ret
      iunlock(ip);
    80003dd0:	8552                	mv	a0,s4
    80003dd2:	00000097          	auipc	ra,0x0
    80003dd6:	994080e7          	jalr	-1644(ra) # 80003766 <iunlock>
      return ip;
    80003dda:	bfe1                	j	80003db2 <namex+0x6c>
      iunlockput(ip);
    80003ddc:	8552                	mv	a0,s4
    80003dde:	00000097          	auipc	ra,0x0
    80003de2:	bce080e7          	jalr	-1074(ra) # 800039ac <iunlockput>
      return 0;
    80003de6:	8a4e                	mv	s4,s3
    80003de8:	b7e9                	j	80003db2 <namex+0x6c>
  len = path - s;
    80003dea:	40998633          	sub	a2,s3,s1
    80003dee:	00060d1b          	sext.w	s10,a2
  if(len >= DIRSIZ)
    80003df2:	09acd863          	bge	s9,s10,80003e82 <namex+0x13c>
    memmove(name, s, DIRSIZ);
    80003df6:	4639                	li	a2,14
    80003df8:	85a6                	mv	a1,s1
    80003dfa:	8556                	mv	a0,s5
    80003dfc:	ffffd097          	auipc	ra,0xffffd
    80003e00:	f1e080e7          	jalr	-226(ra) # 80000d1a <memmove>
    80003e04:	84ce                	mv	s1,s3
  while(*path == '/')
    80003e06:	0004c783          	lbu	a5,0(s1)
    80003e0a:	01279763          	bne	a5,s2,80003e18 <namex+0xd2>
    path++;
    80003e0e:	0485                	addi	s1,s1,1
  while(*path == '/')
    80003e10:	0004c783          	lbu	a5,0(s1)
    80003e14:	ff278de3          	beq	a5,s2,80003e0e <namex+0xc8>
    ilock(ip);
    80003e18:	8552                	mv	a0,s4
    80003e1a:	00000097          	auipc	ra,0x0
    80003e1e:	88a080e7          	jalr	-1910(ra) # 800036a4 <ilock>
    if(ip->type != T_DIR){
    80003e22:	044a1783          	lh	a5,68(s4)
    80003e26:	f98790e3          	bne	a5,s8,80003da6 <namex+0x60>
    if(nameiparent && *path == '\0'){
    80003e2a:	000b0563          	beqz	s6,80003e34 <namex+0xee>
    80003e2e:	0004c783          	lbu	a5,0(s1)
    80003e32:	dfd9                	beqz	a5,80003dd0 <namex+0x8a>
    if((next = dirlookup(ip, name, 0)) == 0){
    80003e34:	865e                	mv	a2,s7
    80003e36:	85d6                	mv	a1,s5
    80003e38:	8552                	mv	a0,s4
    80003e3a:	00000097          	auipc	ra,0x0
    80003e3e:	e5c080e7          	jalr	-420(ra) # 80003c96 <dirlookup>
    80003e42:	89aa                	mv	s3,a0
    80003e44:	dd41                	beqz	a0,80003ddc <namex+0x96>
    iunlockput(ip);
    80003e46:	8552                	mv	a0,s4
    80003e48:	00000097          	auipc	ra,0x0
    80003e4c:	b64080e7          	jalr	-1180(ra) # 800039ac <iunlockput>
    ip = next;
    80003e50:	8a4e                	mv	s4,s3
  while(*path == '/')
    80003e52:	0004c783          	lbu	a5,0(s1)
    80003e56:	01279763          	bne	a5,s2,80003e64 <namex+0x11e>
    path++;
    80003e5a:	0485                	addi	s1,s1,1
  while(*path == '/')
    80003e5c:	0004c783          	lbu	a5,0(s1)
    80003e60:	ff278de3          	beq	a5,s2,80003e5a <namex+0x114>
  if(*path == 0)
    80003e64:	cb9d                	beqz	a5,80003e9a <namex+0x154>
  while(*path != '/' && *path != 0)
    80003e66:	0004c783          	lbu	a5,0(s1)
    80003e6a:	89a6                	mv	s3,s1
  len = path - s;
    80003e6c:	8d5e                	mv	s10,s7
    80003e6e:	865e                	mv	a2,s7
  while(*path != '/' && *path != 0)
    80003e70:	01278963          	beq	a5,s2,80003e82 <namex+0x13c>
    80003e74:	dbbd                	beqz	a5,80003dea <namex+0xa4>
    path++;
    80003e76:	0985                	addi	s3,s3,1
  while(*path != '/' && *path != 0)
    80003e78:	0009c783          	lbu	a5,0(s3)
    80003e7c:	ff279ce3          	bne	a5,s2,80003e74 <namex+0x12e>
    80003e80:	b7ad                	j	80003dea <namex+0xa4>
    memmove(name, s, len);
    80003e82:	2601                	sext.w	a2,a2
    80003e84:	85a6                	mv	a1,s1
    80003e86:	8556                	mv	a0,s5
    80003e88:	ffffd097          	auipc	ra,0xffffd
    80003e8c:	e92080e7          	jalr	-366(ra) # 80000d1a <memmove>
    name[len] = 0;
    80003e90:	9d56                	add	s10,s10,s5
    80003e92:	000d0023          	sb	zero,0(s10)
    80003e96:	84ce                	mv	s1,s3
    80003e98:	b7bd                	j	80003e06 <namex+0xc0>
  if(nameiparent){
    80003e9a:	f00b0ce3          	beqz	s6,80003db2 <namex+0x6c>
    iput(ip);
    80003e9e:	8552                	mv	a0,s4
    80003ea0:	00000097          	auipc	ra,0x0
    80003ea4:	a64080e7          	jalr	-1436(ra) # 80003904 <iput>
    return 0;
    80003ea8:	4a01                	li	s4,0
    80003eaa:	b721                	j	80003db2 <namex+0x6c>

0000000080003eac <dirlink>:
{
    80003eac:	7139                	addi	sp,sp,-64
    80003eae:	fc06                	sd	ra,56(sp)
    80003eb0:	f822                	sd	s0,48(sp)
    80003eb2:	f426                	sd	s1,40(sp)
    80003eb4:	f04a                	sd	s2,32(sp)
    80003eb6:	ec4e                	sd	s3,24(sp)
    80003eb8:	e852                	sd	s4,16(sp)
    80003eba:	0080                	addi	s0,sp,64
    80003ebc:	892a                	mv	s2,a0
    80003ebe:	8a2e                	mv	s4,a1
    80003ec0:	89b2                	mv	s3,a2
  if((ip = dirlookup(dp, name, 0)) != 0){
    80003ec2:	4601                	li	a2,0
    80003ec4:	00000097          	auipc	ra,0x0
    80003ec8:	dd2080e7          	jalr	-558(ra) # 80003c96 <dirlookup>
    80003ecc:	e93d                	bnez	a0,80003f42 <dirlink+0x96>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003ece:	04c92483          	lw	s1,76(s2)
    80003ed2:	c49d                	beqz	s1,80003f00 <dirlink+0x54>
    80003ed4:	4481                	li	s1,0
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003ed6:	4741                	li	a4,16
    80003ed8:	86a6                	mv	a3,s1
    80003eda:	fc040613          	addi	a2,s0,-64
    80003ede:	4581                	li	a1,0
    80003ee0:	854a                	mv	a0,s2
    80003ee2:	00000097          	auipc	ra,0x0
    80003ee6:	b1c080e7          	jalr	-1252(ra) # 800039fe <readi>
    80003eea:	47c1                	li	a5,16
    80003eec:	06f51163          	bne	a0,a5,80003f4e <dirlink+0xa2>
    if(de.inum == 0)
    80003ef0:	fc045783          	lhu	a5,-64(s0)
    80003ef4:	c791                	beqz	a5,80003f00 <dirlink+0x54>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003ef6:	24c1                	addiw	s1,s1,16
    80003ef8:	04c92783          	lw	a5,76(s2)
    80003efc:	fcf4ede3          	bltu	s1,a5,80003ed6 <dirlink+0x2a>
  strncpy(de.name, name, DIRSIZ);
    80003f00:	4639                	li	a2,14
    80003f02:	85d2                	mv	a1,s4
    80003f04:	fc240513          	addi	a0,s0,-62
    80003f08:	ffffd097          	auipc	ra,0xffffd
    80003f0c:	eca080e7          	jalr	-310(ra) # 80000dd2 <strncpy>
  de.inum = inum;
    80003f10:	fd341023          	sh	s3,-64(s0)
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003f14:	4741                	li	a4,16
    80003f16:	86a6                	mv	a3,s1
    80003f18:	fc040613          	addi	a2,s0,-64
    80003f1c:	4581                	li	a1,0
    80003f1e:	854a                	mv	a0,s2
    80003f20:	00000097          	auipc	ra,0x0
    80003f24:	bd6080e7          	jalr	-1066(ra) # 80003af6 <writei>
    80003f28:	872a                	mv	a4,a0
    80003f2a:	47c1                	li	a5,16
  return 0;
    80003f2c:	4501                	li	a0,0
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003f2e:	02f71863          	bne	a4,a5,80003f5e <dirlink+0xb2>
}
    80003f32:	70e2                	ld	ra,56(sp)
    80003f34:	7442                	ld	s0,48(sp)
    80003f36:	74a2                	ld	s1,40(sp)
    80003f38:	7902                	ld	s2,32(sp)
    80003f3a:	69e2                	ld	s3,24(sp)
    80003f3c:	6a42                	ld	s4,16(sp)
    80003f3e:	6121                	addi	sp,sp,64
    80003f40:	8082                	ret
    iput(ip);
    80003f42:	00000097          	auipc	ra,0x0
    80003f46:	9c2080e7          	jalr	-1598(ra) # 80003904 <iput>
    return -1;
    80003f4a:	557d                	li	a0,-1
    80003f4c:	b7dd                	j	80003f32 <dirlink+0x86>
      panic("dirlink read");
    80003f4e:	00004517          	auipc	a0,0x4
    80003f52:	6a250513          	addi	a0,a0,1698 # 800085f0 <syscalls+0x1d0>
    80003f56:	ffffc097          	auipc	ra,0xffffc
    80003f5a:	5d6080e7          	jalr	1494(ra) # 8000052c <panic>
    panic("dirlink");
    80003f5e:	00004517          	auipc	a0,0x4
    80003f62:	7a250513          	addi	a0,a0,1954 # 80008700 <syscalls+0x2e0>
    80003f66:	ffffc097          	auipc	ra,0xffffc
    80003f6a:	5c6080e7          	jalr	1478(ra) # 8000052c <panic>

0000000080003f6e <namei>:

struct inode*
namei(char *path)
{
    80003f6e:	1101                	addi	sp,sp,-32
    80003f70:	ec06                	sd	ra,24(sp)
    80003f72:	e822                	sd	s0,16(sp)
    80003f74:	1000                	addi	s0,sp,32
  char name[DIRSIZ];
  return namex(path, 0, name);
    80003f76:	fe040613          	addi	a2,s0,-32
    80003f7a:	4581                	li	a1,0
    80003f7c:	00000097          	auipc	ra,0x0
    80003f80:	dca080e7          	jalr	-566(ra) # 80003d46 <namex>
}
    80003f84:	60e2                	ld	ra,24(sp)
    80003f86:	6442                	ld	s0,16(sp)
    80003f88:	6105                	addi	sp,sp,32
    80003f8a:	8082                	ret

0000000080003f8c <nameiparent>:

struct inode*
nameiparent(char *path, char *name)
{
    80003f8c:	1141                	addi	sp,sp,-16
    80003f8e:	e406                	sd	ra,8(sp)
    80003f90:	e022                	sd	s0,0(sp)
    80003f92:	0800                	addi	s0,sp,16
    80003f94:	862e                	mv	a2,a1
  return namex(path, 1, name);
    80003f96:	4585                	li	a1,1
    80003f98:	00000097          	auipc	ra,0x0
    80003f9c:	dae080e7          	jalr	-594(ra) # 80003d46 <namex>
}
    80003fa0:	60a2                	ld	ra,8(sp)
    80003fa2:	6402                	ld	s0,0(sp)
    80003fa4:	0141                	addi	sp,sp,16
    80003fa6:	8082                	ret

0000000080003fa8 <write_head>:
// Write in-memory log header to disk.
// This is the true point at which the
// current transaction commits.
static void
write_head(void)
{
    80003fa8:	1101                	addi	sp,sp,-32
    80003faa:	ec06                	sd	ra,24(sp)
    80003fac:	e822                	sd	s0,16(sp)
    80003fae:	e426                	sd	s1,8(sp)
    80003fb0:	e04a                	sd	s2,0(sp)
    80003fb2:	1000                	addi	s0,sp,32
  struct buf *buf = bread(log.dev, log.start);
    80003fb4:	00018917          	auipc	s2,0x18
    80003fb8:	6b490913          	addi	s2,s2,1716 # 8001c668 <log>
    80003fbc:	01892583          	lw	a1,24(s2)
    80003fc0:	02892503          	lw	a0,40(s2)
    80003fc4:	fffff097          	auipc	ra,0xfffff
    80003fc8:	e16080e7          	jalr	-490(ra) # 80002dda <bread>
    80003fcc:	84aa                	mv	s1,a0
  struct logheader *hb = (struct logheader *) (buf->data);
  int i;
  hb->n = log.lh.n;
    80003fce:	02c92683          	lw	a3,44(s2)
    80003fd2:	cd34                	sw	a3,88(a0)
  for (i = 0; i < log.lh.n; i++) {
    80003fd4:	02d05863          	blez	a3,80004004 <write_head+0x5c>
    80003fd8:	00018797          	auipc	a5,0x18
    80003fdc:	6c078793          	addi	a5,a5,1728 # 8001c698 <log+0x30>
    80003fe0:	05c50713          	addi	a4,a0,92
    80003fe4:	36fd                	addiw	a3,a3,-1
    80003fe6:	02069613          	slli	a2,a3,0x20
    80003fea:	01e65693          	srli	a3,a2,0x1e
    80003fee:	00018617          	auipc	a2,0x18
    80003ff2:	6ae60613          	addi	a2,a2,1710 # 8001c69c <log+0x34>
    80003ff6:	96b2                	add	a3,a3,a2
    hb->block[i] = log.lh.block[i];
    80003ff8:	4390                	lw	a2,0(a5)
    80003ffa:	c310                	sw	a2,0(a4)
  for (i = 0; i < log.lh.n; i++) {
    80003ffc:	0791                	addi	a5,a5,4
    80003ffe:	0711                	addi	a4,a4,4
    80004000:	fed79ce3          	bne	a5,a3,80003ff8 <write_head+0x50>
  }
  bwrite(buf);
    80004004:	8526                	mv	a0,s1
    80004006:	fffff097          	auipc	ra,0xfffff
    8000400a:	ec6080e7          	jalr	-314(ra) # 80002ecc <bwrite>
  brelse(buf);
    8000400e:	8526                	mv	a0,s1
    80004010:	fffff097          	auipc	ra,0xfffff
    80004014:	efa080e7          	jalr	-262(ra) # 80002f0a <brelse>
}
    80004018:	60e2                	ld	ra,24(sp)
    8000401a:	6442                	ld	s0,16(sp)
    8000401c:	64a2                	ld	s1,8(sp)
    8000401e:	6902                	ld	s2,0(sp)
    80004020:	6105                	addi	sp,sp,32
    80004022:	8082                	ret

0000000080004024 <install_trans>:
  for (tail = 0; tail < log.lh.n; tail++) {
    80004024:	00018797          	auipc	a5,0x18
    80004028:	6707a783          	lw	a5,1648(a5) # 8001c694 <log+0x2c>
    8000402c:	0af05d63          	blez	a5,800040e6 <install_trans+0xc2>
{
    80004030:	7139                	addi	sp,sp,-64
    80004032:	fc06                	sd	ra,56(sp)
    80004034:	f822                	sd	s0,48(sp)
    80004036:	f426                	sd	s1,40(sp)
    80004038:	f04a                	sd	s2,32(sp)
    8000403a:	ec4e                	sd	s3,24(sp)
    8000403c:	e852                	sd	s4,16(sp)
    8000403e:	e456                	sd	s5,8(sp)
    80004040:	e05a                	sd	s6,0(sp)
    80004042:	0080                	addi	s0,sp,64
    80004044:	8b2a                	mv	s6,a0
    80004046:	00018a97          	auipc	s5,0x18
    8000404a:	652a8a93          	addi	s5,s5,1618 # 8001c698 <log+0x30>
  for (tail = 0; tail < log.lh.n; tail++) {
    8000404e:	4a01                	li	s4,0
    struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
    80004050:	00018997          	auipc	s3,0x18
    80004054:	61898993          	addi	s3,s3,1560 # 8001c668 <log>
    80004058:	a00d                	j	8000407a <install_trans+0x56>
    brelse(lbuf);
    8000405a:	854a                	mv	a0,s2
    8000405c:	fffff097          	auipc	ra,0xfffff
    80004060:	eae080e7          	jalr	-338(ra) # 80002f0a <brelse>
    brelse(dbuf);
    80004064:	8526                	mv	a0,s1
    80004066:	fffff097          	auipc	ra,0xfffff
    8000406a:	ea4080e7          	jalr	-348(ra) # 80002f0a <brelse>
  for (tail = 0; tail < log.lh.n; tail++) {
    8000406e:	2a05                	addiw	s4,s4,1
    80004070:	0a91                	addi	s5,s5,4
    80004072:	02c9a783          	lw	a5,44(s3)
    80004076:	04fa5e63          	bge	s4,a5,800040d2 <install_trans+0xae>
    struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
    8000407a:	0189a583          	lw	a1,24(s3)
    8000407e:	014585bb          	addw	a1,a1,s4
    80004082:	2585                	addiw	a1,a1,1
    80004084:	0289a503          	lw	a0,40(s3)
    80004088:	fffff097          	auipc	ra,0xfffff
    8000408c:	d52080e7          	jalr	-686(ra) # 80002dda <bread>
    80004090:	892a                	mv	s2,a0
    struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst
    80004092:	000aa583          	lw	a1,0(s5)
    80004096:	0289a503          	lw	a0,40(s3)
    8000409a:	fffff097          	auipc	ra,0xfffff
    8000409e:	d40080e7          	jalr	-704(ra) # 80002dda <bread>
    800040a2:	84aa                	mv	s1,a0
    memmove(dbuf->data, lbuf->data, BSIZE);  // copy block to dst
    800040a4:	40000613          	li	a2,1024
    800040a8:	05890593          	addi	a1,s2,88
    800040ac:	05850513          	addi	a0,a0,88
    800040b0:	ffffd097          	auipc	ra,0xffffd
    800040b4:	c6a080e7          	jalr	-918(ra) # 80000d1a <memmove>
    bwrite(dbuf);  // write dst to disk
    800040b8:	8526                	mv	a0,s1
    800040ba:	fffff097          	auipc	ra,0xfffff
    800040be:	e12080e7          	jalr	-494(ra) # 80002ecc <bwrite>
    if(recovering == 0)
    800040c2:	f80b1ce3          	bnez	s6,8000405a <install_trans+0x36>
      bunpin(dbuf);
    800040c6:	8526                	mv	a0,s1
    800040c8:	fffff097          	auipc	ra,0xfffff
    800040cc:	f1c080e7          	jalr	-228(ra) # 80002fe4 <bunpin>
    800040d0:	b769                	j	8000405a <install_trans+0x36>
}
    800040d2:	70e2                	ld	ra,56(sp)
    800040d4:	7442                	ld	s0,48(sp)
    800040d6:	74a2                	ld	s1,40(sp)
    800040d8:	7902                	ld	s2,32(sp)
    800040da:	69e2                	ld	s3,24(sp)
    800040dc:	6a42                	ld	s4,16(sp)
    800040de:	6aa2                	ld	s5,8(sp)
    800040e0:	6b02                	ld	s6,0(sp)
    800040e2:	6121                	addi	sp,sp,64
    800040e4:	8082                	ret
    800040e6:	8082                	ret

00000000800040e8 <initlog>:
{
    800040e8:	7179                	addi	sp,sp,-48
    800040ea:	f406                	sd	ra,40(sp)
    800040ec:	f022                	sd	s0,32(sp)
    800040ee:	ec26                	sd	s1,24(sp)
    800040f0:	e84a                	sd	s2,16(sp)
    800040f2:	e44e                	sd	s3,8(sp)
    800040f4:	1800                	addi	s0,sp,48
    800040f6:	892a                	mv	s2,a0
    800040f8:	89ae                	mv	s3,a1
  initlock(&log.lock, "log");
    800040fa:	00018497          	auipc	s1,0x18
    800040fe:	56e48493          	addi	s1,s1,1390 # 8001c668 <log>
    80004102:	00004597          	auipc	a1,0x4
    80004106:	4fe58593          	addi	a1,a1,1278 # 80008600 <syscalls+0x1e0>
    8000410a:	8526                	mv	a0,s1
    8000410c:	ffffd097          	auipc	ra,0xffffd
    80004110:	a26080e7          	jalr	-1498(ra) # 80000b32 <initlock>
  log.start = sb->logstart;
    80004114:	0149a583          	lw	a1,20(s3)
    80004118:	cc8c                	sw	a1,24(s1)
  log.size = sb->nlog;
    8000411a:	0109a783          	lw	a5,16(s3)
    8000411e:	ccdc                	sw	a5,28(s1)
  log.dev = dev;
    80004120:	0324a423          	sw	s2,40(s1)
  struct buf *buf = bread(log.dev, log.start);
    80004124:	854a                	mv	a0,s2
    80004126:	fffff097          	auipc	ra,0xfffff
    8000412a:	cb4080e7          	jalr	-844(ra) # 80002dda <bread>
  log.lh.n = lh->n;
    8000412e:	4d34                	lw	a3,88(a0)
    80004130:	d4d4                	sw	a3,44(s1)
  for (i = 0; i < log.lh.n; i++) {
    80004132:	02d05663          	blez	a3,8000415e <initlog+0x76>
    80004136:	05c50793          	addi	a5,a0,92
    8000413a:	00018717          	auipc	a4,0x18
    8000413e:	55e70713          	addi	a4,a4,1374 # 8001c698 <log+0x30>
    80004142:	36fd                	addiw	a3,a3,-1
    80004144:	02069613          	slli	a2,a3,0x20
    80004148:	01e65693          	srli	a3,a2,0x1e
    8000414c:	06050613          	addi	a2,a0,96
    80004150:	96b2                	add	a3,a3,a2
    log.lh.block[i] = lh->block[i];
    80004152:	4390                	lw	a2,0(a5)
    80004154:	c310                	sw	a2,0(a4)
  for (i = 0; i < log.lh.n; i++) {
    80004156:	0791                	addi	a5,a5,4
    80004158:	0711                	addi	a4,a4,4
    8000415a:	fed79ce3          	bne	a5,a3,80004152 <initlog+0x6a>
  brelse(buf);
    8000415e:	fffff097          	auipc	ra,0xfffff
    80004162:	dac080e7          	jalr	-596(ra) # 80002f0a <brelse>

static void
recover_from_log(void)
{
  read_head();
  install_trans(1); // if committed, copy from log to disk
    80004166:	4505                	li	a0,1
    80004168:	00000097          	auipc	ra,0x0
    8000416c:	ebc080e7          	jalr	-324(ra) # 80004024 <install_trans>
  log.lh.n = 0;
    80004170:	00018797          	auipc	a5,0x18
    80004174:	5207a223          	sw	zero,1316(a5) # 8001c694 <log+0x2c>
  write_head(); // clear the log
    80004178:	00000097          	auipc	ra,0x0
    8000417c:	e30080e7          	jalr	-464(ra) # 80003fa8 <write_head>
}
    80004180:	70a2                	ld	ra,40(sp)
    80004182:	7402                	ld	s0,32(sp)
    80004184:	64e2                	ld	s1,24(sp)
    80004186:	6942                	ld	s2,16(sp)
    80004188:	69a2                	ld	s3,8(sp)
    8000418a:	6145                	addi	sp,sp,48
    8000418c:	8082                	ret

000000008000418e <begin_op>:
}

// called at the start of each FS system call.
void
begin_op(void)
{
    8000418e:	1101                	addi	sp,sp,-32
    80004190:	ec06                	sd	ra,24(sp)
    80004192:	e822                	sd	s0,16(sp)
    80004194:	e426                	sd	s1,8(sp)
    80004196:	e04a                	sd	s2,0(sp)
    80004198:	1000                	addi	s0,sp,32
  acquire(&log.lock);
    8000419a:	00018517          	auipc	a0,0x18
    8000419e:	4ce50513          	addi	a0,a0,1230 # 8001c668 <log>
    800041a2:	ffffd097          	auipc	ra,0xffffd
    800041a6:	a20080e7          	jalr	-1504(ra) # 80000bc2 <acquire>
  while(1){
    if(log.committing){
    800041aa:	00018497          	auipc	s1,0x18
    800041ae:	4be48493          	addi	s1,s1,1214 # 8001c668 <log>
      sleep(&log, &log.lock);
    } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    800041b2:	4979                	li	s2,30
    800041b4:	a039                	j	800041c2 <begin_op+0x34>
      sleep(&log, &log.lock);
    800041b6:	85a6                	mv	a1,s1
    800041b8:	8526                	mv	a0,s1
    800041ba:	ffffe097          	auipc	ra,0xffffe
    800041be:	008080e7          	jalr	8(ra) # 800021c2 <sleep>
    if(log.committing){
    800041c2:	50dc                	lw	a5,36(s1)
    800041c4:	fbed                	bnez	a5,800041b6 <begin_op+0x28>
    } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    800041c6:	5098                	lw	a4,32(s1)
    800041c8:	2705                	addiw	a4,a4,1
    800041ca:	0007069b          	sext.w	a3,a4
    800041ce:	0027179b          	slliw	a5,a4,0x2
    800041d2:	9fb9                	addw	a5,a5,a4
    800041d4:	0017979b          	slliw	a5,a5,0x1
    800041d8:	54d8                	lw	a4,44(s1)
    800041da:	9fb9                	addw	a5,a5,a4
    800041dc:	00f95963          	bge	s2,a5,800041ee <begin_op+0x60>
      // this op might exhaust log space; wait for commit.
      sleep(&log, &log.lock);
    800041e0:	85a6                	mv	a1,s1
    800041e2:	8526                	mv	a0,s1
    800041e4:	ffffe097          	auipc	ra,0xffffe
    800041e8:	fde080e7          	jalr	-34(ra) # 800021c2 <sleep>
    800041ec:	bfd9                	j	800041c2 <begin_op+0x34>
    } else {
      log.outstanding += 1;
    800041ee:	00018517          	auipc	a0,0x18
    800041f2:	47a50513          	addi	a0,a0,1146 # 8001c668 <log>
    800041f6:	d114                	sw	a3,32(a0)
      release(&log.lock);
    800041f8:	ffffd097          	auipc	ra,0xffffd
    800041fc:	a7e080e7          	jalr	-1410(ra) # 80000c76 <release>
      break;
    }
  }
}
    80004200:	60e2                	ld	ra,24(sp)
    80004202:	6442                	ld	s0,16(sp)
    80004204:	64a2                	ld	s1,8(sp)
    80004206:	6902                	ld	s2,0(sp)
    80004208:	6105                	addi	sp,sp,32
    8000420a:	8082                	ret

000000008000420c <end_op>:

// called at the end of each FS system call.
// commits if this was the last outstanding operation.
void
end_op(void)
{
    8000420c:	7139                	addi	sp,sp,-64
    8000420e:	fc06                	sd	ra,56(sp)
    80004210:	f822                	sd	s0,48(sp)
    80004212:	f426                	sd	s1,40(sp)
    80004214:	f04a                	sd	s2,32(sp)
    80004216:	ec4e                	sd	s3,24(sp)
    80004218:	e852                	sd	s4,16(sp)
    8000421a:	e456                	sd	s5,8(sp)
    8000421c:	0080                	addi	s0,sp,64
  int do_commit = 0;

  acquire(&log.lock);
    8000421e:	00018497          	auipc	s1,0x18
    80004222:	44a48493          	addi	s1,s1,1098 # 8001c668 <log>
    80004226:	8526                	mv	a0,s1
    80004228:	ffffd097          	auipc	ra,0xffffd
    8000422c:	99a080e7          	jalr	-1638(ra) # 80000bc2 <acquire>
  log.outstanding -= 1;
    80004230:	509c                	lw	a5,32(s1)
    80004232:	37fd                	addiw	a5,a5,-1
    80004234:	0007891b          	sext.w	s2,a5
    80004238:	d09c                	sw	a5,32(s1)
  if(log.committing)
    8000423a:	50dc                	lw	a5,36(s1)
    8000423c:	e7b9                	bnez	a5,8000428a <end_op+0x7e>
    panic("log.committing");
  if(log.outstanding == 0){
    8000423e:	04091e63          	bnez	s2,8000429a <end_op+0x8e>
    do_commit = 1;
    log.committing = 1;
    80004242:	00018497          	auipc	s1,0x18
    80004246:	42648493          	addi	s1,s1,1062 # 8001c668 <log>
    8000424a:	4785                	li	a5,1
    8000424c:	d0dc                	sw	a5,36(s1)
    // begin_op() may be waiting for log space,
    // and decrementing log.outstanding has decreased
    // the amount of reserved space.
    wakeup(&log);
  }
  release(&log.lock);
    8000424e:	8526                	mv	a0,s1
    80004250:	ffffd097          	auipc	ra,0xffffd
    80004254:	a26080e7          	jalr	-1498(ra) # 80000c76 <release>
}

static void
commit()
{
  if (log.lh.n > 0) {
    80004258:	54dc                	lw	a5,44(s1)
    8000425a:	06f04763          	bgtz	a5,800042c8 <end_op+0xbc>
    acquire(&log.lock);
    8000425e:	00018497          	auipc	s1,0x18
    80004262:	40a48493          	addi	s1,s1,1034 # 8001c668 <log>
    80004266:	8526                	mv	a0,s1
    80004268:	ffffd097          	auipc	ra,0xffffd
    8000426c:	95a080e7          	jalr	-1702(ra) # 80000bc2 <acquire>
    log.committing = 0;
    80004270:	0204a223          	sw	zero,36(s1)
    wakeup(&log);
    80004274:	8526                	mv	a0,s1
    80004276:	ffffe097          	auipc	ra,0xffffe
    8000427a:	0cc080e7          	jalr	204(ra) # 80002342 <wakeup>
    release(&log.lock);
    8000427e:	8526                	mv	a0,s1
    80004280:	ffffd097          	auipc	ra,0xffffd
    80004284:	9f6080e7          	jalr	-1546(ra) # 80000c76 <release>
}
    80004288:	a03d                	j	800042b6 <end_op+0xaa>
    panic("log.committing");
    8000428a:	00004517          	auipc	a0,0x4
    8000428e:	37e50513          	addi	a0,a0,894 # 80008608 <syscalls+0x1e8>
    80004292:	ffffc097          	auipc	ra,0xffffc
    80004296:	29a080e7          	jalr	666(ra) # 8000052c <panic>
    wakeup(&log);
    8000429a:	00018497          	auipc	s1,0x18
    8000429e:	3ce48493          	addi	s1,s1,974 # 8001c668 <log>
    800042a2:	8526                	mv	a0,s1
    800042a4:	ffffe097          	auipc	ra,0xffffe
    800042a8:	09e080e7          	jalr	158(ra) # 80002342 <wakeup>
  release(&log.lock);
    800042ac:	8526                	mv	a0,s1
    800042ae:	ffffd097          	auipc	ra,0xffffd
    800042b2:	9c8080e7          	jalr	-1592(ra) # 80000c76 <release>
}
    800042b6:	70e2                	ld	ra,56(sp)
    800042b8:	7442                	ld	s0,48(sp)
    800042ba:	74a2                	ld	s1,40(sp)
    800042bc:	7902                	ld	s2,32(sp)
    800042be:	69e2                	ld	s3,24(sp)
    800042c0:	6a42                	ld	s4,16(sp)
    800042c2:	6aa2                	ld	s5,8(sp)
    800042c4:	6121                	addi	sp,sp,64
    800042c6:	8082                	ret
  for (tail = 0; tail < log.lh.n; tail++) {
    800042c8:	00018a97          	auipc	s5,0x18
    800042cc:	3d0a8a93          	addi	s5,s5,976 # 8001c698 <log+0x30>
    struct buf *to = bread(log.dev, log.start+tail+1); // log block
    800042d0:	00018a17          	auipc	s4,0x18
    800042d4:	398a0a13          	addi	s4,s4,920 # 8001c668 <log>
    800042d8:	018a2583          	lw	a1,24(s4)
    800042dc:	012585bb          	addw	a1,a1,s2
    800042e0:	2585                	addiw	a1,a1,1
    800042e2:	028a2503          	lw	a0,40(s4)
    800042e6:	fffff097          	auipc	ra,0xfffff
    800042ea:	af4080e7          	jalr	-1292(ra) # 80002dda <bread>
    800042ee:	84aa                	mv	s1,a0
    struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block
    800042f0:	000aa583          	lw	a1,0(s5)
    800042f4:	028a2503          	lw	a0,40(s4)
    800042f8:	fffff097          	auipc	ra,0xfffff
    800042fc:	ae2080e7          	jalr	-1310(ra) # 80002dda <bread>
    80004300:	89aa                	mv	s3,a0
    memmove(to->data, from->data, BSIZE);
    80004302:	40000613          	li	a2,1024
    80004306:	05850593          	addi	a1,a0,88
    8000430a:	05848513          	addi	a0,s1,88
    8000430e:	ffffd097          	auipc	ra,0xffffd
    80004312:	a0c080e7          	jalr	-1524(ra) # 80000d1a <memmove>
    bwrite(to);  // write the log
    80004316:	8526                	mv	a0,s1
    80004318:	fffff097          	auipc	ra,0xfffff
    8000431c:	bb4080e7          	jalr	-1100(ra) # 80002ecc <bwrite>
    brelse(from);
    80004320:	854e                	mv	a0,s3
    80004322:	fffff097          	auipc	ra,0xfffff
    80004326:	be8080e7          	jalr	-1048(ra) # 80002f0a <brelse>
    brelse(to);
    8000432a:	8526                	mv	a0,s1
    8000432c:	fffff097          	auipc	ra,0xfffff
    80004330:	bde080e7          	jalr	-1058(ra) # 80002f0a <brelse>
  for (tail = 0; tail < log.lh.n; tail++) {
    80004334:	2905                	addiw	s2,s2,1
    80004336:	0a91                	addi	s5,s5,4
    80004338:	02ca2783          	lw	a5,44(s4)
    8000433c:	f8f94ee3          	blt	s2,a5,800042d8 <end_op+0xcc>
    write_log();     // Write modified blocks from cache to log
    write_head();    // Write header to disk -- the real commit
    80004340:	00000097          	auipc	ra,0x0
    80004344:	c68080e7          	jalr	-920(ra) # 80003fa8 <write_head>
    install_trans(0); // Now install writes to home locations
    80004348:	4501                	li	a0,0
    8000434a:	00000097          	auipc	ra,0x0
    8000434e:	cda080e7          	jalr	-806(ra) # 80004024 <install_trans>
    log.lh.n = 0;
    80004352:	00018797          	auipc	a5,0x18
    80004356:	3407a123          	sw	zero,834(a5) # 8001c694 <log+0x2c>
    write_head();    // Erase the transaction from the log
    8000435a:	00000097          	auipc	ra,0x0
    8000435e:	c4e080e7          	jalr	-946(ra) # 80003fa8 <write_head>
    80004362:	bdf5                	j	8000425e <end_op+0x52>

0000000080004364 <log_write>:
//   modify bp->data[]
//   log_write(bp)
//   brelse(bp)
void
log_write(struct buf *b)
{
    80004364:	1101                	addi	sp,sp,-32
    80004366:	ec06                	sd	ra,24(sp)
    80004368:	e822                	sd	s0,16(sp)
    8000436a:	e426                	sd	s1,8(sp)
    8000436c:	e04a                	sd	s2,0(sp)
    8000436e:	1000                	addi	s0,sp,32
  int i;

  if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1)
    80004370:	00018717          	auipc	a4,0x18
    80004374:	32472703          	lw	a4,804(a4) # 8001c694 <log+0x2c>
    80004378:	47f5                	li	a5,29
    8000437a:	08e7c063          	blt	a5,a4,800043fa <log_write+0x96>
    8000437e:	84aa                	mv	s1,a0
    80004380:	00018797          	auipc	a5,0x18
    80004384:	3047a783          	lw	a5,772(a5) # 8001c684 <log+0x1c>
    80004388:	37fd                	addiw	a5,a5,-1
    8000438a:	06f75863          	bge	a4,a5,800043fa <log_write+0x96>
    panic("too big a transaction");
  if (log.outstanding < 1)
    8000438e:	00018797          	auipc	a5,0x18
    80004392:	2fa7a783          	lw	a5,762(a5) # 8001c688 <log+0x20>
    80004396:	06f05a63          	blez	a5,8000440a <log_write+0xa6>
    panic("log_write outside of trans");

  acquire(&log.lock);
    8000439a:	00018917          	auipc	s2,0x18
    8000439e:	2ce90913          	addi	s2,s2,718 # 8001c668 <log>
    800043a2:	854a                	mv	a0,s2
    800043a4:	ffffd097          	auipc	ra,0xffffd
    800043a8:	81e080e7          	jalr	-2018(ra) # 80000bc2 <acquire>
  for (i = 0; i < log.lh.n; i++) {
    800043ac:	02c92603          	lw	a2,44(s2)
    800043b0:	06c05563          	blez	a2,8000441a <log_write+0xb6>
    if (log.lh.block[i] == b->blockno)   // log absorbtion
    800043b4:	44cc                	lw	a1,12(s1)
    800043b6:	00018717          	auipc	a4,0x18
    800043ba:	2e270713          	addi	a4,a4,738 # 8001c698 <log+0x30>
  for (i = 0; i < log.lh.n; i++) {
    800043be:	4781                	li	a5,0
    if (log.lh.block[i] == b->blockno)   // log absorbtion
    800043c0:	4314                	lw	a3,0(a4)
    800043c2:	04b68d63          	beq	a3,a1,8000441c <log_write+0xb8>
  for (i = 0; i < log.lh.n; i++) {
    800043c6:	2785                	addiw	a5,a5,1
    800043c8:	0711                	addi	a4,a4,4
    800043ca:	fec79be3          	bne	a5,a2,800043c0 <log_write+0x5c>
      break;
  }
  log.lh.block[i] = b->blockno;
    800043ce:	0621                	addi	a2,a2,8
    800043d0:	060a                	slli	a2,a2,0x2
    800043d2:	00018797          	auipc	a5,0x18
    800043d6:	29678793          	addi	a5,a5,662 # 8001c668 <log>
    800043da:	97b2                	add	a5,a5,a2
    800043dc:	44d8                	lw	a4,12(s1)
    800043de:	cb98                	sw	a4,16(a5)
  if (i == log.lh.n) {  // Add new block to log?
    bpin(b);
    800043e0:	8526                	mv	a0,s1
    800043e2:	fffff097          	auipc	ra,0xfffff
    800043e6:	bc6080e7          	jalr	-1082(ra) # 80002fa8 <bpin>
    log.lh.n++;
    800043ea:	00018717          	auipc	a4,0x18
    800043ee:	27e70713          	addi	a4,a4,638 # 8001c668 <log>
    800043f2:	575c                	lw	a5,44(a4)
    800043f4:	2785                	addiw	a5,a5,1
    800043f6:	d75c                	sw	a5,44(a4)
    800043f8:	a835                	j	80004434 <log_write+0xd0>
    panic("too big a transaction");
    800043fa:	00004517          	auipc	a0,0x4
    800043fe:	21e50513          	addi	a0,a0,542 # 80008618 <syscalls+0x1f8>
    80004402:	ffffc097          	auipc	ra,0xffffc
    80004406:	12a080e7          	jalr	298(ra) # 8000052c <panic>
    panic("log_write outside of trans");
    8000440a:	00004517          	auipc	a0,0x4
    8000440e:	22650513          	addi	a0,a0,550 # 80008630 <syscalls+0x210>
    80004412:	ffffc097          	auipc	ra,0xffffc
    80004416:	11a080e7          	jalr	282(ra) # 8000052c <panic>
  for (i = 0; i < log.lh.n; i++) {
    8000441a:	4781                	li	a5,0
  log.lh.block[i] = b->blockno;
    8000441c:	00878693          	addi	a3,a5,8
    80004420:	068a                	slli	a3,a3,0x2
    80004422:	00018717          	auipc	a4,0x18
    80004426:	24670713          	addi	a4,a4,582 # 8001c668 <log>
    8000442a:	9736                	add	a4,a4,a3
    8000442c:	44d4                	lw	a3,12(s1)
    8000442e:	cb14                	sw	a3,16(a4)
  if (i == log.lh.n) {  // Add new block to log?
    80004430:	faf608e3          	beq	a2,a5,800043e0 <log_write+0x7c>
  }
  release(&log.lock);
    80004434:	00018517          	auipc	a0,0x18
    80004438:	23450513          	addi	a0,a0,564 # 8001c668 <log>
    8000443c:	ffffd097          	auipc	ra,0xffffd
    80004440:	83a080e7          	jalr	-1990(ra) # 80000c76 <release>
}
    80004444:	60e2                	ld	ra,24(sp)
    80004446:	6442                	ld	s0,16(sp)
    80004448:	64a2                	ld	s1,8(sp)
    8000444a:	6902                	ld	s2,0(sp)
    8000444c:	6105                	addi	sp,sp,32
    8000444e:	8082                	ret

0000000080004450 <initsleeplock>:
#include "proc.h"
#include "sleeplock.h"

void
initsleeplock(struct sleeplock *lk, char *name)
{
    80004450:	1101                	addi	sp,sp,-32
    80004452:	ec06                	sd	ra,24(sp)
    80004454:	e822                	sd	s0,16(sp)
    80004456:	e426                	sd	s1,8(sp)
    80004458:	e04a                	sd	s2,0(sp)
    8000445a:	1000                	addi	s0,sp,32
    8000445c:	84aa                	mv	s1,a0
    8000445e:	892e                	mv	s2,a1
  initlock(&lk->lk, "sleep lock");
    80004460:	00004597          	auipc	a1,0x4
    80004464:	1f058593          	addi	a1,a1,496 # 80008650 <syscalls+0x230>
    80004468:	0521                	addi	a0,a0,8
    8000446a:	ffffc097          	auipc	ra,0xffffc
    8000446e:	6c8080e7          	jalr	1736(ra) # 80000b32 <initlock>
  lk->name = name;
    80004472:	0324b023          	sd	s2,32(s1)
  lk->locked = 0;
    80004476:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    8000447a:	0204a423          	sw	zero,40(s1)
}
    8000447e:	60e2                	ld	ra,24(sp)
    80004480:	6442                	ld	s0,16(sp)
    80004482:	64a2                	ld	s1,8(sp)
    80004484:	6902                	ld	s2,0(sp)
    80004486:	6105                	addi	sp,sp,32
    80004488:	8082                	ret

000000008000448a <acquiresleep>:

void
acquiresleep(struct sleeplock *lk)
{
    8000448a:	1101                	addi	sp,sp,-32
    8000448c:	ec06                	sd	ra,24(sp)
    8000448e:	e822                	sd	s0,16(sp)
    80004490:	e426                	sd	s1,8(sp)
    80004492:	e04a                	sd	s2,0(sp)
    80004494:	1000                	addi	s0,sp,32
    80004496:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    80004498:	00850913          	addi	s2,a0,8
    8000449c:	854a                	mv	a0,s2
    8000449e:	ffffc097          	auipc	ra,0xffffc
    800044a2:	724080e7          	jalr	1828(ra) # 80000bc2 <acquire>
  while (lk->locked) {
    800044a6:	409c                	lw	a5,0(s1)
    800044a8:	cb89                	beqz	a5,800044ba <acquiresleep+0x30>
    sleep(lk, &lk->lk);
    800044aa:	85ca                	mv	a1,s2
    800044ac:	8526                	mv	a0,s1
    800044ae:	ffffe097          	auipc	ra,0xffffe
    800044b2:	d14080e7          	jalr	-748(ra) # 800021c2 <sleep>
  while (lk->locked) {
    800044b6:	409c                	lw	a5,0(s1)
    800044b8:	fbed                	bnez	a5,800044aa <acquiresleep+0x20>
  }
  lk->locked = 1;
    800044ba:	4785                	li	a5,1
    800044bc:	c09c                	sw	a5,0(s1)
  lk->pid = myproc()->pid;
    800044be:	ffffd097          	auipc	ra,0xffffd
    800044c2:	4ec080e7          	jalr	1260(ra) # 800019aa <myproc>
    800044c6:	5d1c                	lw	a5,56(a0)
    800044c8:	d49c                	sw	a5,40(s1)
  release(&lk->lk);
    800044ca:	854a                	mv	a0,s2
    800044cc:	ffffc097          	auipc	ra,0xffffc
    800044d0:	7aa080e7          	jalr	1962(ra) # 80000c76 <release>
}
    800044d4:	60e2                	ld	ra,24(sp)
    800044d6:	6442                	ld	s0,16(sp)
    800044d8:	64a2                	ld	s1,8(sp)
    800044da:	6902                	ld	s2,0(sp)
    800044dc:	6105                	addi	sp,sp,32
    800044de:	8082                	ret

00000000800044e0 <releasesleep>:

void
releasesleep(struct sleeplock *lk)
{
    800044e0:	1101                	addi	sp,sp,-32
    800044e2:	ec06                	sd	ra,24(sp)
    800044e4:	e822                	sd	s0,16(sp)
    800044e6:	e426                	sd	s1,8(sp)
    800044e8:	e04a                	sd	s2,0(sp)
    800044ea:	1000                	addi	s0,sp,32
    800044ec:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    800044ee:	00850913          	addi	s2,a0,8
    800044f2:	854a                	mv	a0,s2
    800044f4:	ffffc097          	auipc	ra,0xffffc
    800044f8:	6ce080e7          	jalr	1742(ra) # 80000bc2 <acquire>
  lk->locked = 0;
    800044fc:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    80004500:	0204a423          	sw	zero,40(s1)
  wakeup(lk);
    80004504:	8526                	mv	a0,s1
    80004506:	ffffe097          	auipc	ra,0xffffe
    8000450a:	e3c080e7          	jalr	-452(ra) # 80002342 <wakeup>
  release(&lk->lk);
    8000450e:	854a                	mv	a0,s2
    80004510:	ffffc097          	auipc	ra,0xffffc
    80004514:	766080e7          	jalr	1894(ra) # 80000c76 <release>
}
    80004518:	60e2                	ld	ra,24(sp)
    8000451a:	6442                	ld	s0,16(sp)
    8000451c:	64a2                	ld	s1,8(sp)
    8000451e:	6902                	ld	s2,0(sp)
    80004520:	6105                	addi	sp,sp,32
    80004522:	8082                	ret

0000000080004524 <holdingsleep>:

int
holdingsleep(struct sleeplock *lk)
{
    80004524:	7179                	addi	sp,sp,-48
    80004526:	f406                	sd	ra,40(sp)
    80004528:	f022                	sd	s0,32(sp)
    8000452a:	ec26                	sd	s1,24(sp)
    8000452c:	e84a                	sd	s2,16(sp)
    8000452e:	e44e                	sd	s3,8(sp)
    80004530:	1800                	addi	s0,sp,48
    80004532:	84aa                	mv	s1,a0
  int r;
  
  acquire(&lk->lk);
    80004534:	00850913          	addi	s2,a0,8
    80004538:	854a                	mv	a0,s2
    8000453a:	ffffc097          	auipc	ra,0xffffc
    8000453e:	688080e7          	jalr	1672(ra) # 80000bc2 <acquire>
  r = lk->locked && (lk->pid == myproc()->pid);
    80004542:	409c                	lw	a5,0(s1)
    80004544:	ef99                	bnez	a5,80004562 <holdingsleep+0x3e>
    80004546:	4481                	li	s1,0
  release(&lk->lk);
    80004548:	854a                	mv	a0,s2
    8000454a:	ffffc097          	auipc	ra,0xffffc
    8000454e:	72c080e7          	jalr	1836(ra) # 80000c76 <release>
  return r;
}
    80004552:	8526                	mv	a0,s1
    80004554:	70a2                	ld	ra,40(sp)
    80004556:	7402                	ld	s0,32(sp)
    80004558:	64e2                	ld	s1,24(sp)
    8000455a:	6942                	ld	s2,16(sp)
    8000455c:	69a2                	ld	s3,8(sp)
    8000455e:	6145                	addi	sp,sp,48
    80004560:	8082                	ret
  r = lk->locked && (lk->pid == myproc()->pid);
    80004562:	0284a983          	lw	s3,40(s1)
    80004566:	ffffd097          	auipc	ra,0xffffd
    8000456a:	444080e7          	jalr	1092(ra) # 800019aa <myproc>
    8000456e:	5d04                	lw	s1,56(a0)
    80004570:	413484b3          	sub	s1,s1,s3
    80004574:	0014b493          	seqz	s1,s1
    80004578:	bfc1                	j	80004548 <holdingsleep+0x24>

000000008000457a <fileinit>:
  struct file file[NFILE];
} ftable;

void
fileinit(void)
{
    8000457a:	1141                	addi	sp,sp,-16
    8000457c:	e406                	sd	ra,8(sp)
    8000457e:	e022                	sd	s0,0(sp)
    80004580:	0800                	addi	s0,sp,16
  initlock(&ftable.lock, "ftable");
    80004582:	00004597          	auipc	a1,0x4
    80004586:	0de58593          	addi	a1,a1,222 # 80008660 <syscalls+0x240>
    8000458a:	00018517          	auipc	a0,0x18
    8000458e:	22650513          	addi	a0,a0,550 # 8001c7b0 <ftable>
    80004592:	ffffc097          	auipc	ra,0xffffc
    80004596:	5a0080e7          	jalr	1440(ra) # 80000b32 <initlock>
}
    8000459a:	60a2                	ld	ra,8(sp)
    8000459c:	6402                	ld	s0,0(sp)
    8000459e:	0141                	addi	sp,sp,16
    800045a0:	8082                	ret

00000000800045a2 <filealloc>:

// Allocate a file structure.
struct file*
filealloc(void)
{
    800045a2:	1101                	addi	sp,sp,-32
    800045a4:	ec06                	sd	ra,24(sp)
    800045a6:	e822                	sd	s0,16(sp)
    800045a8:	e426                	sd	s1,8(sp)
    800045aa:	1000                	addi	s0,sp,32
  struct file *f;

  acquire(&ftable.lock);
    800045ac:	00018517          	auipc	a0,0x18
    800045b0:	20450513          	addi	a0,a0,516 # 8001c7b0 <ftable>
    800045b4:	ffffc097          	auipc	ra,0xffffc
    800045b8:	60e080e7          	jalr	1550(ra) # 80000bc2 <acquire>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    800045bc:	00018497          	auipc	s1,0x18
    800045c0:	20c48493          	addi	s1,s1,524 # 8001c7c8 <ftable+0x18>
    800045c4:	00019717          	auipc	a4,0x19
    800045c8:	1a470713          	addi	a4,a4,420 # 8001d768 <ftable+0xfb8>
    if(f->ref == 0){
    800045cc:	40dc                	lw	a5,4(s1)
    800045ce:	cf99                	beqz	a5,800045ec <filealloc+0x4a>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    800045d0:	02848493          	addi	s1,s1,40
    800045d4:	fee49ce3          	bne	s1,a4,800045cc <filealloc+0x2a>
      f->ref = 1;
      release(&ftable.lock);
      return f;
    }
  }
  release(&ftable.lock);
    800045d8:	00018517          	auipc	a0,0x18
    800045dc:	1d850513          	addi	a0,a0,472 # 8001c7b0 <ftable>
    800045e0:	ffffc097          	auipc	ra,0xffffc
    800045e4:	696080e7          	jalr	1686(ra) # 80000c76 <release>
  return 0;
    800045e8:	4481                	li	s1,0
    800045ea:	a819                	j	80004600 <filealloc+0x5e>
      f->ref = 1;
    800045ec:	4785                	li	a5,1
    800045ee:	c0dc                	sw	a5,4(s1)
      release(&ftable.lock);
    800045f0:	00018517          	auipc	a0,0x18
    800045f4:	1c050513          	addi	a0,a0,448 # 8001c7b0 <ftable>
    800045f8:	ffffc097          	auipc	ra,0xffffc
    800045fc:	67e080e7          	jalr	1662(ra) # 80000c76 <release>
}
    80004600:	8526                	mv	a0,s1
    80004602:	60e2                	ld	ra,24(sp)
    80004604:	6442                	ld	s0,16(sp)
    80004606:	64a2                	ld	s1,8(sp)
    80004608:	6105                	addi	sp,sp,32
    8000460a:	8082                	ret

000000008000460c <filedup>:

// Increment ref count for file f.
struct file*
filedup(struct file *f)
{
    8000460c:	1101                	addi	sp,sp,-32
    8000460e:	ec06                	sd	ra,24(sp)
    80004610:	e822                	sd	s0,16(sp)
    80004612:	e426                	sd	s1,8(sp)
    80004614:	1000                	addi	s0,sp,32
    80004616:	84aa                	mv	s1,a0
  acquire(&ftable.lock);
    80004618:	00018517          	auipc	a0,0x18
    8000461c:	19850513          	addi	a0,a0,408 # 8001c7b0 <ftable>
    80004620:	ffffc097          	auipc	ra,0xffffc
    80004624:	5a2080e7          	jalr	1442(ra) # 80000bc2 <acquire>
  if(f->ref < 1)
    80004628:	40dc                	lw	a5,4(s1)
    8000462a:	02f05263          	blez	a5,8000464e <filedup+0x42>
    panic("filedup");
  f->ref++;
    8000462e:	2785                	addiw	a5,a5,1
    80004630:	c0dc                	sw	a5,4(s1)
  release(&ftable.lock);
    80004632:	00018517          	auipc	a0,0x18
    80004636:	17e50513          	addi	a0,a0,382 # 8001c7b0 <ftable>
    8000463a:	ffffc097          	auipc	ra,0xffffc
    8000463e:	63c080e7          	jalr	1596(ra) # 80000c76 <release>
  return f;
}
    80004642:	8526                	mv	a0,s1
    80004644:	60e2                	ld	ra,24(sp)
    80004646:	6442                	ld	s0,16(sp)
    80004648:	64a2                	ld	s1,8(sp)
    8000464a:	6105                	addi	sp,sp,32
    8000464c:	8082                	ret
    panic("filedup");
    8000464e:	00004517          	auipc	a0,0x4
    80004652:	01a50513          	addi	a0,a0,26 # 80008668 <syscalls+0x248>
    80004656:	ffffc097          	auipc	ra,0xffffc
    8000465a:	ed6080e7          	jalr	-298(ra) # 8000052c <panic>

000000008000465e <fileclose>:

// Close file f.  (Decrement ref count, close when reaches 0.)
void
fileclose(struct file *f)
{
    8000465e:	7139                	addi	sp,sp,-64
    80004660:	fc06                	sd	ra,56(sp)
    80004662:	f822                	sd	s0,48(sp)
    80004664:	f426                	sd	s1,40(sp)
    80004666:	f04a                	sd	s2,32(sp)
    80004668:	ec4e                	sd	s3,24(sp)
    8000466a:	e852                	sd	s4,16(sp)
    8000466c:	e456                	sd	s5,8(sp)
    8000466e:	0080                	addi	s0,sp,64
    80004670:	84aa                	mv	s1,a0
  struct file ff;

  acquire(&ftable.lock);
    80004672:	00018517          	auipc	a0,0x18
    80004676:	13e50513          	addi	a0,a0,318 # 8001c7b0 <ftable>
    8000467a:	ffffc097          	auipc	ra,0xffffc
    8000467e:	548080e7          	jalr	1352(ra) # 80000bc2 <acquire>
  if(f->ref < 1)
    80004682:	40dc                	lw	a5,4(s1)
    80004684:	06f05163          	blez	a5,800046e6 <fileclose+0x88>
    panic("fileclose");
  if(--f->ref > 0){
    80004688:	37fd                	addiw	a5,a5,-1
    8000468a:	0007871b          	sext.w	a4,a5
    8000468e:	c0dc                	sw	a5,4(s1)
    80004690:	06e04363          	bgtz	a4,800046f6 <fileclose+0x98>
    release(&ftable.lock);
    return;
  }
  ff = *f;
    80004694:	0004a903          	lw	s2,0(s1)
    80004698:	0094ca83          	lbu	s5,9(s1)
    8000469c:	0104ba03          	ld	s4,16(s1)
    800046a0:	0184b983          	ld	s3,24(s1)
  f->ref = 0;
    800046a4:	0004a223          	sw	zero,4(s1)
  f->type = FD_NONE;
    800046a8:	0004a023          	sw	zero,0(s1)
  release(&ftable.lock);
    800046ac:	00018517          	auipc	a0,0x18
    800046b0:	10450513          	addi	a0,a0,260 # 8001c7b0 <ftable>
    800046b4:	ffffc097          	auipc	ra,0xffffc
    800046b8:	5c2080e7          	jalr	1474(ra) # 80000c76 <release>

  if(ff.type == FD_PIPE){
    800046bc:	4785                	li	a5,1
    800046be:	04f90d63          	beq	s2,a5,80004718 <fileclose+0xba>
    pipeclose(ff.pipe, ff.writable);
  } else if(ff.type == FD_INODE || ff.type == FD_DEVICE){
    800046c2:	3979                	addiw	s2,s2,-2
    800046c4:	4785                	li	a5,1
    800046c6:	0527e063          	bltu	a5,s2,80004706 <fileclose+0xa8>
    begin_op();
    800046ca:	00000097          	auipc	ra,0x0
    800046ce:	ac4080e7          	jalr	-1340(ra) # 8000418e <begin_op>
    iput(ff.ip);
    800046d2:	854e                	mv	a0,s3
    800046d4:	fffff097          	auipc	ra,0xfffff
    800046d8:	230080e7          	jalr	560(ra) # 80003904 <iput>
    end_op();
    800046dc:	00000097          	auipc	ra,0x0
    800046e0:	b30080e7          	jalr	-1232(ra) # 8000420c <end_op>
    800046e4:	a00d                	j	80004706 <fileclose+0xa8>
    panic("fileclose");
    800046e6:	00004517          	auipc	a0,0x4
    800046ea:	f8a50513          	addi	a0,a0,-118 # 80008670 <syscalls+0x250>
    800046ee:	ffffc097          	auipc	ra,0xffffc
    800046f2:	e3e080e7          	jalr	-450(ra) # 8000052c <panic>
    release(&ftable.lock);
    800046f6:	00018517          	auipc	a0,0x18
    800046fa:	0ba50513          	addi	a0,a0,186 # 8001c7b0 <ftable>
    800046fe:	ffffc097          	auipc	ra,0xffffc
    80004702:	578080e7          	jalr	1400(ra) # 80000c76 <release>
  }
}
    80004706:	70e2                	ld	ra,56(sp)
    80004708:	7442                	ld	s0,48(sp)
    8000470a:	74a2                	ld	s1,40(sp)
    8000470c:	7902                	ld	s2,32(sp)
    8000470e:	69e2                	ld	s3,24(sp)
    80004710:	6a42                	ld	s4,16(sp)
    80004712:	6aa2                	ld	s5,8(sp)
    80004714:	6121                	addi	sp,sp,64
    80004716:	8082                	ret
    pipeclose(ff.pipe, ff.writable);
    80004718:	85d6                	mv	a1,s5
    8000471a:	8552                	mv	a0,s4
    8000471c:	00000097          	auipc	ra,0x0
    80004720:	34c080e7          	jalr	844(ra) # 80004a68 <pipeclose>
    80004724:	b7cd                	j	80004706 <fileclose+0xa8>

0000000080004726 <filestat>:

// Get metadata about file f.
// addr is a user virtual address, pointing to a struct stat.
int
filestat(struct file *f, uint64 addr)
{
    80004726:	715d                	addi	sp,sp,-80
    80004728:	e486                	sd	ra,72(sp)
    8000472a:	e0a2                	sd	s0,64(sp)
    8000472c:	fc26                	sd	s1,56(sp)
    8000472e:	f84a                	sd	s2,48(sp)
    80004730:	f44e                	sd	s3,40(sp)
    80004732:	0880                	addi	s0,sp,80
    80004734:	84aa                	mv	s1,a0
    80004736:	89ae                	mv	s3,a1
  struct proc *p = myproc();
    80004738:	ffffd097          	auipc	ra,0xffffd
    8000473c:	272080e7          	jalr	626(ra) # 800019aa <myproc>
  struct stat st;
  
  if(f->type == FD_INODE || f->type == FD_DEVICE){
    80004740:	409c                	lw	a5,0(s1)
    80004742:	37f9                	addiw	a5,a5,-2
    80004744:	4705                	li	a4,1
    80004746:	04f76763          	bltu	a4,a5,80004794 <filestat+0x6e>
    8000474a:	892a                	mv	s2,a0
    ilock(f->ip);
    8000474c:	6c88                	ld	a0,24(s1)
    8000474e:	fffff097          	auipc	ra,0xfffff
    80004752:	f56080e7          	jalr	-170(ra) # 800036a4 <ilock>
    stati(f->ip, &st);
    80004756:	fb840593          	addi	a1,s0,-72
    8000475a:	6c88                	ld	a0,24(s1)
    8000475c:	fffff097          	auipc	ra,0xfffff
    80004760:	278080e7          	jalr	632(ra) # 800039d4 <stati>
    iunlock(f->ip);
    80004764:	6c88                	ld	a0,24(s1)
    80004766:	fffff097          	auipc	ra,0xfffff
    8000476a:	000080e7          	jalr	ra # 80003766 <iunlock>
    if(copyout(p->pagetable, addr, (char *)&st, sizeof(st)) < 0)
    8000476e:	46e1                	li	a3,24
    80004770:	fb840613          	addi	a2,s0,-72
    80004774:	85ce                	mv	a1,s3
    80004776:	05093503          	ld	a0,80(s2)
    8000477a:	ffffd097          	auipc	ra,0xffffd
    8000477e:	ec8080e7          	jalr	-312(ra) # 80001642 <copyout>
    80004782:	41f5551b          	sraiw	a0,a0,0x1f
      return -1;
    return 0;
  }
  return -1;
}
    80004786:	60a6                	ld	ra,72(sp)
    80004788:	6406                	ld	s0,64(sp)
    8000478a:	74e2                	ld	s1,56(sp)
    8000478c:	7942                	ld	s2,48(sp)
    8000478e:	79a2                	ld	s3,40(sp)
    80004790:	6161                	addi	sp,sp,80
    80004792:	8082                	ret
  return -1;
    80004794:	557d                	li	a0,-1
    80004796:	bfc5                	j	80004786 <filestat+0x60>

0000000080004798 <fileread>:

// Read from file f.
// addr is a user virtual address.
int
fileread(struct file *f, uint64 addr, int n)
{
    80004798:	7179                	addi	sp,sp,-48
    8000479a:	f406                	sd	ra,40(sp)
    8000479c:	f022                	sd	s0,32(sp)
    8000479e:	ec26                	sd	s1,24(sp)
    800047a0:	e84a                	sd	s2,16(sp)
    800047a2:	e44e                	sd	s3,8(sp)
    800047a4:	1800                	addi	s0,sp,48
  int r = 0;

  if(f->readable == 0)
    800047a6:	00854783          	lbu	a5,8(a0)
    800047aa:	c3d5                	beqz	a5,8000484e <fileread+0xb6>
    800047ac:	84aa                	mv	s1,a0
    800047ae:	89ae                	mv	s3,a1
    800047b0:	8932                	mv	s2,a2
    return -1;

  if(f->type == FD_PIPE){
    800047b2:	411c                	lw	a5,0(a0)
    800047b4:	4705                	li	a4,1
    800047b6:	04e78963          	beq	a5,a4,80004808 <fileread+0x70>
    r = piperead(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    800047ba:	470d                	li	a4,3
    800047bc:	04e78d63          	beq	a5,a4,80004816 <fileread+0x7e>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
      return -1;
    r = devsw[f->major].read(1, addr, n);
  } else if(f->type == FD_INODE){
    800047c0:	4709                	li	a4,2
    800047c2:	06e79e63          	bne	a5,a4,8000483e <fileread+0xa6>
    ilock(f->ip);
    800047c6:	6d08                	ld	a0,24(a0)
    800047c8:	fffff097          	auipc	ra,0xfffff
    800047cc:	edc080e7          	jalr	-292(ra) # 800036a4 <ilock>
    if((r = readi(f->ip, 1, addr, f->off, n)) > 0)
    800047d0:	874a                	mv	a4,s2
    800047d2:	5094                	lw	a3,32(s1)
    800047d4:	864e                	mv	a2,s3
    800047d6:	4585                	li	a1,1
    800047d8:	6c88                	ld	a0,24(s1)
    800047da:	fffff097          	auipc	ra,0xfffff
    800047de:	224080e7          	jalr	548(ra) # 800039fe <readi>
    800047e2:	892a                	mv	s2,a0
    800047e4:	00a05563          	blez	a0,800047ee <fileread+0x56>
      f->off += r;
    800047e8:	509c                	lw	a5,32(s1)
    800047ea:	9fa9                	addw	a5,a5,a0
    800047ec:	d09c                	sw	a5,32(s1)
    iunlock(f->ip);
    800047ee:	6c88                	ld	a0,24(s1)
    800047f0:	fffff097          	auipc	ra,0xfffff
    800047f4:	f76080e7          	jalr	-138(ra) # 80003766 <iunlock>
  } else {
    panic("fileread");
  }

  return r;
}
    800047f8:	854a                	mv	a0,s2
    800047fa:	70a2                	ld	ra,40(sp)
    800047fc:	7402                	ld	s0,32(sp)
    800047fe:	64e2                	ld	s1,24(sp)
    80004800:	6942                	ld	s2,16(sp)
    80004802:	69a2                	ld	s3,8(sp)
    80004804:	6145                	addi	sp,sp,48
    80004806:	8082                	ret
    r = piperead(f->pipe, addr, n);
    80004808:	6908                	ld	a0,16(a0)
    8000480a:	00000097          	auipc	ra,0x0
    8000480e:	3c0080e7          	jalr	960(ra) # 80004bca <piperead>
    80004812:	892a                	mv	s2,a0
    80004814:	b7d5                	j	800047f8 <fileread+0x60>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
    80004816:	02451783          	lh	a5,36(a0)
    8000481a:	03079693          	slli	a3,a5,0x30
    8000481e:	92c1                	srli	a3,a3,0x30
    80004820:	4725                	li	a4,9
    80004822:	02d76863          	bltu	a4,a3,80004852 <fileread+0xba>
    80004826:	0792                	slli	a5,a5,0x4
    80004828:	00018717          	auipc	a4,0x18
    8000482c:	ee870713          	addi	a4,a4,-280 # 8001c710 <devsw>
    80004830:	97ba                	add	a5,a5,a4
    80004832:	639c                	ld	a5,0(a5)
    80004834:	c38d                	beqz	a5,80004856 <fileread+0xbe>
    r = devsw[f->major].read(1, addr, n);
    80004836:	4505                	li	a0,1
    80004838:	9782                	jalr	a5
    8000483a:	892a                	mv	s2,a0
    8000483c:	bf75                	j	800047f8 <fileread+0x60>
    panic("fileread");
    8000483e:	00004517          	auipc	a0,0x4
    80004842:	e4250513          	addi	a0,a0,-446 # 80008680 <syscalls+0x260>
    80004846:	ffffc097          	auipc	ra,0xffffc
    8000484a:	ce6080e7          	jalr	-794(ra) # 8000052c <panic>
    return -1;
    8000484e:	597d                	li	s2,-1
    80004850:	b765                	j	800047f8 <fileread+0x60>
      return -1;
    80004852:	597d                	li	s2,-1
    80004854:	b755                	j	800047f8 <fileread+0x60>
    80004856:	597d                	li	s2,-1
    80004858:	b745                	j	800047f8 <fileread+0x60>

000000008000485a <filewrite>:

// Write to file f.
// addr is a user virtual address.
int
filewrite(struct file *f, uint64 addr, int n)
{
    8000485a:	715d                	addi	sp,sp,-80
    8000485c:	e486                	sd	ra,72(sp)
    8000485e:	e0a2                	sd	s0,64(sp)
    80004860:	fc26                	sd	s1,56(sp)
    80004862:	f84a                	sd	s2,48(sp)
    80004864:	f44e                	sd	s3,40(sp)
    80004866:	f052                	sd	s4,32(sp)
    80004868:	ec56                	sd	s5,24(sp)
    8000486a:	e85a                	sd	s6,16(sp)
    8000486c:	e45e                	sd	s7,8(sp)
    8000486e:	e062                	sd	s8,0(sp)
    80004870:	0880                	addi	s0,sp,80
  int r, ret = 0;

  if(f->writable == 0)
    80004872:	00954783          	lbu	a5,9(a0)
    80004876:	10078663          	beqz	a5,80004982 <filewrite+0x128>
    8000487a:	892a                	mv	s2,a0
    8000487c:	8b2e                	mv	s6,a1
    8000487e:	8a32                	mv	s4,a2
    return -1;

  if(f->type == FD_PIPE){
    80004880:	411c                	lw	a5,0(a0)
    80004882:	4705                	li	a4,1
    80004884:	02e78263          	beq	a5,a4,800048a8 <filewrite+0x4e>
    ret = pipewrite(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    80004888:	470d                	li	a4,3
    8000488a:	02e78663          	beq	a5,a4,800048b6 <filewrite+0x5c>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
      return -1;
    ret = devsw[f->major].write(1, addr, n);
  } else if(f->type == FD_INODE){
    8000488e:	4709                	li	a4,2
    80004890:	0ee79163          	bne	a5,a4,80004972 <filewrite+0x118>
    // and 2 blocks of slop for non-aligned writes.
    // this really belongs lower down, since writei()
    // might be writing a device like the console.
    int max = ((MAXOPBLOCKS-1-1-2) / 2) * BSIZE;
    int i = 0;
    while(i < n){
    80004894:	0ac05d63          	blez	a2,8000494e <filewrite+0xf4>
    int i = 0;
    80004898:	4981                	li	s3,0
    8000489a:	6b85                	lui	s7,0x1
    8000489c:	c00b8b93          	addi	s7,s7,-1024 # c00 <_entry-0x7ffff400>
    800048a0:	6c05                	lui	s8,0x1
    800048a2:	c00c0c1b          	addiw	s8,s8,-1024 # c00 <_entry-0x7ffff400>
    800048a6:	a861                	j	8000493e <filewrite+0xe4>
    ret = pipewrite(f->pipe, addr, n);
    800048a8:	6908                	ld	a0,16(a0)
    800048aa:	00000097          	auipc	ra,0x0
    800048ae:	22e080e7          	jalr	558(ra) # 80004ad8 <pipewrite>
    800048b2:	8a2a                	mv	s4,a0
    800048b4:	a045                	j	80004954 <filewrite+0xfa>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
    800048b6:	02451783          	lh	a5,36(a0)
    800048ba:	03079693          	slli	a3,a5,0x30
    800048be:	92c1                	srli	a3,a3,0x30
    800048c0:	4725                	li	a4,9
    800048c2:	0cd76263          	bltu	a4,a3,80004986 <filewrite+0x12c>
    800048c6:	0792                	slli	a5,a5,0x4
    800048c8:	00018717          	auipc	a4,0x18
    800048cc:	e4870713          	addi	a4,a4,-440 # 8001c710 <devsw>
    800048d0:	97ba                	add	a5,a5,a4
    800048d2:	679c                	ld	a5,8(a5)
    800048d4:	cbdd                	beqz	a5,8000498a <filewrite+0x130>
    ret = devsw[f->major].write(1, addr, n);
    800048d6:	4505                	li	a0,1
    800048d8:	9782                	jalr	a5
    800048da:	8a2a                	mv	s4,a0
    800048dc:	a8a5                	j	80004954 <filewrite+0xfa>
    800048de:	00048a9b          	sext.w	s5,s1
      int n1 = n - i;
      if(n1 > max)
        n1 = max;

      begin_op();
    800048e2:	00000097          	auipc	ra,0x0
    800048e6:	8ac080e7          	jalr	-1876(ra) # 8000418e <begin_op>
      ilock(f->ip);
    800048ea:	01893503          	ld	a0,24(s2)
    800048ee:	fffff097          	auipc	ra,0xfffff
    800048f2:	db6080e7          	jalr	-586(ra) # 800036a4 <ilock>
      if ((r = writei(f->ip, 1, addr + i, f->off, n1)) > 0)
    800048f6:	8756                	mv	a4,s5
    800048f8:	02092683          	lw	a3,32(s2)
    800048fc:	01698633          	add	a2,s3,s6
    80004900:	4585                	li	a1,1
    80004902:	01893503          	ld	a0,24(s2)
    80004906:	fffff097          	auipc	ra,0xfffff
    8000490a:	1f0080e7          	jalr	496(ra) # 80003af6 <writei>
    8000490e:	84aa                	mv	s1,a0
    80004910:	00a05763          	blez	a0,8000491e <filewrite+0xc4>
        f->off += r;
    80004914:	02092783          	lw	a5,32(s2)
    80004918:	9fa9                	addw	a5,a5,a0
    8000491a:	02f92023          	sw	a5,32(s2)
      iunlock(f->ip);
    8000491e:	01893503          	ld	a0,24(s2)
    80004922:	fffff097          	auipc	ra,0xfffff
    80004926:	e44080e7          	jalr	-444(ra) # 80003766 <iunlock>
      end_op();
    8000492a:	00000097          	auipc	ra,0x0
    8000492e:	8e2080e7          	jalr	-1822(ra) # 8000420c <end_op>

      if(r != n1){
    80004932:	009a9f63          	bne	s5,s1,80004950 <filewrite+0xf6>
        // error from writei
        break;
      }
      i += r;
    80004936:	013489bb          	addw	s3,s1,s3
    while(i < n){
    8000493a:	0149db63          	bge	s3,s4,80004950 <filewrite+0xf6>
      int n1 = n - i;
    8000493e:	413a04bb          	subw	s1,s4,s3
    80004942:	0004879b          	sext.w	a5,s1
    80004946:	f8fbdce3          	bge	s7,a5,800048de <filewrite+0x84>
    8000494a:	84e2                	mv	s1,s8
    8000494c:	bf49                	j	800048de <filewrite+0x84>
    int i = 0;
    8000494e:	4981                	li	s3,0
    }
    ret = (i == n ? n : -1);
    80004950:	013a1f63          	bne	s4,s3,8000496e <filewrite+0x114>
  } else {
    panic("filewrite");
  }

  return ret;
}
    80004954:	8552                	mv	a0,s4
    80004956:	60a6                	ld	ra,72(sp)
    80004958:	6406                	ld	s0,64(sp)
    8000495a:	74e2                	ld	s1,56(sp)
    8000495c:	7942                	ld	s2,48(sp)
    8000495e:	79a2                	ld	s3,40(sp)
    80004960:	7a02                	ld	s4,32(sp)
    80004962:	6ae2                	ld	s5,24(sp)
    80004964:	6b42                	ld	s6,16(sp)
    80004966:	6ba2                	ld	s7,8(sp)
    80004968:	6c02                	ld	s8,0(sp)
    8000496a:	6161                	addi	sp,sp,80
    8000496c:	8082                	ret
    ret = (i == n ? n : -1);
    8000496e:	5a7d                	li	s4,-1
    80004970:	b7d5                	j	80004954 <filewrite+0xfa>
    panic("filewrite");
    80004972:	00004517          	auipc	a0,0x4
    80004976:	d1e50513          	addi	a0,a0,-738 # 80008690 <syscalls+0x270>
    8000497a:	ffffc097          	auipc	ra,0xffffc
    8000497e:	bb2080e7          	jalr	-1102(ra) # 8000052c <panic>
    return -1;
    80004982:	5a7d                	li	s4,-1
    80004984:	bfc1                	j	80004954 <filewrite+0xfa>
      return -1;
    80004986:	5a7d                	li	s4,-1
    80004988:	b7f1                	j	80004954 <filewrite+0xfa>
    8000498a:	5a7d                	li	s4,-1
    8000498c:	b7e1                	j	80004954 <filewrite+0xfa>

000000008000498e <pipealloc>:
  int writeopen;  // write fd is still open
};

int
pipealloc(struct file **f0, struct file **f1)
{
    8000498e:	7179                	addi	sp,sp,-48
    80004990:	f406                	sd	ra,40(sp)
    80004992:	f022                	sd	s0,32(sp)
    80004994:	ec26                	sd	s1,24(sp)
    80004996:	e84a                	sd	s2,16(sp)
    80004998:	e44e                	sd	s3,8(sp)
    8000499a:	e052                	sd	s4,0(sp)
    8000499c:	1800                	addi	s0,sp,48
    8000499e:	84aa                	mv	s1,a0
    800049a0:	8a2e                	mv	s4,a1
  struct pipe *pi;

  pi = 0;
  *f0 = *f1 = 0;
    800049a2:	0005b023          	sd	zero,0(a1)
    800049a6:	00053023          	sd	zero,0(a0)
  if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0)
    800049aa:	00000097          	auipc	ra,0x0
    800049ae:	bf8080e7          	jalr	-1032(ra) # 800045a2 <filealloc>
    800049b2:	e088                	sd	a0,0(s1)
    800049b4:	c551                	beqz	a0,80004a40 <pipealloc+0xb2>
    800049b6:	00000097          	auipc	ra,0x0
    800049ba:	bec080e7          	jalr	-1044(ra) # 800045a2 <filealloc>
    800049be:	00aa3023          	sd	a0,0(s4)
    800049c2:	c92d                	beqz	a0,80004a34 <pipealloc+0xa6>
    goto bad;
  if((pi = (struct pipe*)kalloc()) == 0)
    800049c4:	ffffc097          	auipc	ra,0xffffc
    800049c8:	10e080e7          	jalr	270(ra) # 80000ad2 <kalloc>
    800049cc:	892a                	mv	s2,a0
    800049ce:	c125                	beqz	a0,80004a2e <pipealloc+0xa0>
    goto bad;
  pi->readopen = 1;
    800049d0:	4985                	li	s3,1
    800049d2:	23352023          	sw	s3,544(a0)
  pi->writeopen = 1;
    800049d6:	23352223          	sw	s3,548(a0)
  pi->nwrite = 0;
    800049da:	20052e23          	sw	zero,540(a0)
  pi->nread = 0;
    800049de:	20052c23          	sw	zero,536(a0)
  initlock(&pi->lock, "pipe");
    800049e2:	00004597          	auipc	a1,0x4
    800049e6:	cbe58593          	addi	a1,a1,-834 # 800086a0 <syscalls+0x280>
    800049ea:	ffffc097          	auipc	ra,0xffffc
    800049ee:	148080e7          	jalr	328(ra) # 80000b32 <initlock>
  (*f0)->type = FD_PIPE;
    800049f2:	609c                	ld	a5,0(s1)
    800049f4:	0137a023          	sw	s3,0(a5)
  (*f0)->readable = 1;
    800049f8:	609c                	ld	a5,0(s1)
    800049fa:	01378423          	sb	s3,8(a5)
  (*f0)->writable = 0;
    800049fe:	609c                	ld	a5,0(s1)
    80004a00:	000784a3          	sb	zero,9(a5)
  (*f0)->pipe = pi;
    80004a04:	609c                	ld	a5,0(s1)
    80004a06:	0127b823          	sd	s2,16(a5)
  (*f1)->type = FD_PIPE;
    80004a0a:	000a3783          	ld	a5,0(s4)
    80004a0e:	0137a023          	sw	s3,0(a5)
  (*f1)->readable = 0;
    80004a12:	000a3783          	ld	a5,0(s4)
    80004a16:	00078423          	sb	zero,8(a5)
  (*f1)->writable = 1;
    80004a1a:	000a3783          	ld	a5,0(s4)
    80004a1e:	013784a3          	sb	s3,9(a5)
  (*f1)->pipe = pi;
    80004a22:	000a3783          	ld	a5,0(s4)
    80004a26:	0127b823          	sd	s2,16(a5)
  return 0;
    80004a2a:	4501                	li	a0,0
    80004a2c:	a025                	j	80004a54 <pipealloc+0xc6>

 bad:
  if(pi)
    kfree((char*)pi);
  if(*f0)
    80004a2e:	6088                	ld	a0,0(s1)
    80004a30:	e501                	bnez	a0,80004a38 <pipealloc+0xaa>
    80004a32:	a039                	j	80004a40 <pipealloc+0xb2>
    80004a34:	6088                	ld	a0,0(s1)
    80004a36:	c51d                	beqz	a0,80004a64 <pipealloc+0xd6>
    fileclose(*f0);
    80004a38:	00000097          	auipc	ra,0x0
    80004a3c:	c26080e7          	jalr	-986(ra) # 8000465e <fileclose>
  if(*f1)
    80004a40:	000a3783          	ld	a5,0(s4)
    fileclose(*f1);
  return -1;
    80004a44:	557d                	li	a0,-1
  if(*f1)
    80004a46:	c799                	beqz	a5,80004a54 <pipealloc+0xc6>
    fileclose(*f1);
    80004a48:	853e                	mv	a0,a5
    80004a4a:	00000097          	auipc	ra,0x0
    80004a4e:	c14080e7          	jalr	-1004(ra) # 8000465e <fileclose>
  return -1;
    80004a52:	557d                	li	a0,-1
}
    80004a54:	70a2                	ld	ra,40(sp)
    80004a56:	7402                	ld	s0,32(sp)
    80004a58:	64e2                	ld	s1,24(sp)
    80004a5a:	6942                	ld	s2,16(sp)
    80004a5c:	69a2                	ld	s3,8(sp)
    80004a5e:	6a02                	ld	s4,0(sp)
    80004a60:	6145                	addi	sp,sp,48
    80004a62:	8082                	ret
  return -1;
    80004a64:	557d                	li	a0,-1
    80004a66:	b7fd                	j	80004a54 <pipealloc+0xc6>

0000000080004a68 <pipeclose>:

void
pipeclose(struct pipe *pi, int writable)
{
    80004a68:	1101                	addi	sp,sp,-32
    80004a6a:	ec06                	sd	ra,24(sp)
    80004a6c:	e822                	sd	s0,16(sp)
    80004a6e:	e426                	sd	s1,8(sp)
    80004a70:	e04a                	sd	s2,0(sp)
    80004a72:	1000                	addi	s0,sp,32
    80004a74:	84aa                	mv	s1,a0
    80004a76:	892e                	mv	s2,a1
  acquire(&pi->lock);
    80004a78:	ffffc097          	auipc	ra,0xffffc
    80004a7c:	14a080e7          	jalr	330(ra) # 80000bc2 <acquire>
  if(writable){
    80004a80:	02090d63          	beqz	s2,80004aba <pipeclose+0x52>
    pi->writeopen = 0;
    80004a84:	2204a223          	sw	zero,548(s1)
    wakeup(&pi->nread);
    80004a88:	21848513          	addi	a0,s1,536
    80004a8c:	ffffe097          	auipc	ra,0xffffe
    80004a90:	8b6080e7          	jalr	-1866(ra) # 80002342 <wakeup>
  } else {
    pi->readopen = 0;
    wakeup(&pi->nwrite);
  }
  if(pi->readopen == 0 && pi->writeopen == 0){
    80004a94:	2204b783          	ld	a5,544(s1)
    80004a98:	eb95                	bnez	a5,80004acc <pipeclose+0x64>
    release(&pi->lock);
    80004a9a:	8526                	mv	a0,s1
    80004a9c:	ffffc097          	auipc	ra,0xffffc
    80004aa0:	1da080e7          	jalr	474(ra) # 80000c76 <release>
    kfree((char*)pi);
    80004aa4:	8526                	mv	a0,s1
    80004aa6:	ffffc097          	auipc	ra,0xffffc
    80004aaa:	f2e080e7          	jalr	-210(ra) # 800009d4 <kfree>
  } else
    release(&pi->lock);
}
    80004aae:	60e2                	ld	ra,24(sp)
    80004ab0:	6442                	ld	s0,16(sp)
    80004ab2:	64a2                	ld	s1,8(sp)
    80004ab4:	6902                	ld	s2,0(sp)
    80004ab6:	6105                	addi	sp,sp,32
    80004ab8:	8082                	ret
    pi->readopen = 0;
    80004aba:	2204a023          	sw	zero,544(s1)
    wakeup(&pi->nwrite);
    80004abe:	21c48513          	addi	a0,s1,540
    80004ac2:	ffffe097          	auipc	ra,0xffffe
    80004ac6:	880080e7          	jalr	-1920(ra) # 80002342 <wakeup>
    80004aca:	b7e9                	j	80004a94 <pipeclose+0x2c>
    release(&pi->lock);
    80004acc:	8526                	mv	a0,s1
    80004ace:	ffffc097          	auipc	ra,0xffffc
    80004ad2:	1a8080e7          	jalr	424(ra) # 80000c76 <release>
}
    80004ad6:	bfe1                	j	80004aae <pipeclose+0x46>

0000000080004ad8 <pipewrite>:

int
pipewrite(struct pipe *pi, uint64 addr, int n)
{
    80004ad8:	711d                	addi	sp,sp,-96
    80004ada:	ec86                	sd	ra,88(sp)
    80004adc:	e8a2                	sd	s0,80(sp)
    80004ade:	e4a6                	sd	s1,72(sp)
    80004ae0:	e0ca                	sd	s2,64(sp)
    80004ae2:	fc4e                	sd	s3,56(sp)
    80004ae4:	f852                	sd	s4,48(sp)
    80004ae6:	f456                	sd	s5,40(sp)
    80004ae8:	f05a                	sd	s6,32(sp)
    80004aea:	ec5e                	sd	s7,24(sp)
    80004aec:	e862                	sd	s8,16(sp)
    80004aee:	1080                	addi	s0,sp,96
    80004af0:	84aa                	mv	s1,a0
    80004af2:	8aae                	mv	s5,a1
    80004af4:	8a32                	mv	s4,a2
  int i = 0;
  struct proc *pr = myproc();
    80004af6:	ffffd097          	auipc	ra,0xffffd
    80004afa:	eb4080e7          	jalr	-332(ra) # 800019aa <myproc>
    80004afe:	89aa                	mv	s3,a0

  acquire(&pi->lock);
    80004b00:	8526                	mv	a0,s1
    80004b02:	ffffc097          	auipc	ra,0xffffc
    80004b06:	0c0080e7          	jalr	192(ra) # 80000bc2 <acquire>
  while(i < n){
    80004b0a:	0b405363          	blez	s4,80004bb0 <pipewrite+0xd8>
  int i = 0;
    80004b0e:	4901                	li	s2,0
    if(pi->nwrite == pi->nread + PIPESIZE){ //DOC: pipewrite-full
      wakeup(&pi->nread);
      sleep(&pi->nwrite, &pi->lock);
    } else {
      char ch;
      if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    80004b10:	5b7d                	li	s6,-1
      wakeup(&pi->nread);
    80004b12:	21848c13          	addi	s8,s1,536
      sleep(&pi->nwrite, &pi->lock);
    80004b16:	21c48b93          	addi	s7,s1,540
    80004b1a:	a089                	j	80004b5c <pipewrite+0x84>
      release(&pi->lock);
    80004b1c:	8526                	mv	a0,s1
    80004b1e:	ffffc097          	auipc	ra,0xffffc
    80004b22:	158080e7          	jalr	344(ra) # 80000c76 <release>
      return -1;
    80004b26:	597d                	li	s2,-1
  }
  wakeup(&pi->nread);
  release(&pi->lock);

  return i;
}
    80004b28:	854a                	mv	a0,s2
    80004b2a:	60e6                	ld	ra,88(sp)
    80004b2c:	6446                	ld	s0,80(sp)
    80004b2e:	64a6                	ld	s1,72(sp)
    80004b30:	6906                	ld	s2,64(sp)
    80004b32:	79e2                	ld	s3,56(sp)
    80004b34:	7a42                	ld	s4,48(sp)
    80004b36:	7aa2                	ld	s5,40(sp)
    80004b38:	7b02                	ld	s6,32(sp)
    80004b3a:	6be2                	ld	s7,24(sp)
    80004b3c:	6c42                	ld	s8,16(sp)
    80004b3e:	6125                	addi	sp,sp,96
    80004b40:	8082                	ret
      wakeup(&pi->nread);
    80004b42:	8562                	mv	a0,s8
    80004b44:	ffffd097          	auipc	ra,0xffffd
    80004b48:	7fe080e7          	jalr	2046(ra) # 80002342 <wakeup>
      sleep(&pi->nwrite, &pi->lock);
    80004b4c:	85a6                	mv	a1,s1
    80004b4e:	855e                	mv	a0,s7
    80004b50:	ffffd097          	auipc	ra,0xffffd
    80004b54:	672080e7          	jalr	1650(ra) # 800021c2 <sleep>
  while(i < n){
    80004b58:	05495d63          	bge	s2,s4,80004bb2 <pipewrite+0xda>
    if(pi->readopen == 0 || pr->killed){
    80004b5c:	2204a783          	lw	a5,544(s1)
    80004b60:	dfd5                	beqz	a5,80004b1c <pipewrite+0x44>
    80004b62:	0309a783          	lw	a5,48(s3)
    80004b66:	fbdd                	bnez	a5,80004b1c <pipewrite+0x44>
    if(pi->nwrite == pi->nread + PIPESIZE){ //DOC: pipewrite-full
    80004b68:	2184a783          	lw	a5,536(s1)
    80004b6c:	21c4a703          	lw	a4,540(s1)
    80004b70:	2007879b          	addiw	a5,a5,512
    80004b74:	fcf707e3          	beq	a4,a5,80004b42 <pipewrite+0x6a>
      if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    80004b78:	4685                	li	a3,1
    80004b7a:	01590633          	add	a2,s2,s5
    80004b7e:	faf40593          	addi	a1,s0,-81
    80004b82:	0509b503          	ld	a0,80(s3)
    80004b86:	ffffd097          	auipc	ra,0xffffd
    80004b8a:	b48080e7          	jalr	-1208(ra) # 800016ce <copyin>
    80004b8e:	03650263          	beq	a0,s6,80004bb2 <pipewrite+0xda>
      pi->data[pi->nwrite++ % PIPESIZE] = ch;
    80004b92:	21c4a783          	lw	a5,540(s1)
    80004b96:	0017871b          	addiw	a4,a5,1
    80004b9a:	20e4ae23          	sw	a4,540(s1)
    80004b9e:	1ff7f793          	andi	a5,a5,511
    80004ba2:	97a6                	add	a5,a5,s1
    80004ba4:	faf44703          	lbu	a4,-81(s0)
    80004ba8:	00e78c23          	sb	a4,24(a5)
      i++;
    80004bac:	2905                	addiw	s2,s2,1
    80004bae:	b76d                	j	80004b58 <pipewrite+0x80>
  int i = 0;
    80004bb0:	4901                	li	s2,0
  wakeup(&pi->nread);
    80004bb2:	21848513          	addi	a0,s1,536
    80004bb6:	ffffd097          	auipc	ra,0xffffd
    80004bba:	78c080e7          	jalr	1932(ra) # 80002342 <wakeup>
  release(&pi->lock);
    80004bbe:	8526                	mv	a0,s1
    80004bc0:	ffffc097          	auipc	ra,0xffffc
    80004bc4:	0b6080e7          	jalr	182(ra) # 80000c76 <release>
  return i;
    80004bc8:	b785                	j	80004b28 <pipewrite+0x50>

0000000080004bca <piperead>:

int
piperead(struct pipe *pi, uint64 addr, int n)
{
    80004bca:	715d                	addi	sp,sp,-80
    80004bcc:	e486                	sd	ra,72(sp)
    80004bce:	e0a2                	sd	s0,64(sp)
    80004bd0:	fc26                	sd	s1,56(sp)
    80004bd2:	f84a                	sd	s2,48(sp)
    80004bd4:	f44e                	sd	s3,40(sp)
    80004bd6:	f052                	sd	s4,32(sp)
    80004bd8:	ec56                	sd	s5,24(sp)
    80004bda:	e85a                	sd	s6,16(sp)
    80004bdc:	0880                	addi	s0,sp,80
    80004bde:	84aa                	mv	s1,a0
    80004be0:	892e                	mv	s2,a1
    80004be2:	8ab2                	mv	s5,a2
  int i;
  struct proc *pr = myproc();
    80004be4:	ffffd097          	auipc	ra,0xffffd
    80004be8:	dc6080e7          	jalr	-570(ra) # 800019aa <myproc>
    80004bec:	8a2a                	mv	s4,a0
  char ch;

  acquire(&pi->lock);
    80004bee:	8526                	mv	a0,s1
    80004bf0:	ffffc097          	auipc	ra,0xffffc
    80004bf4:	fd2080e7          	jalr	-46(ra) # 80000bc2 <acquire>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80004bf8:	2184a703          	lw	a4,536(s1)
    80004bfc:	21c4a783          	lw	a5,540(s1)
    if(pr->killed){
      release(&pi->lock);
      return -1;
    }
    sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
    80004c00:	21848993          	addi	s3,s1,536
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80004c04:	02f71463          	bne	a4,a5,80004c2c <piperead+0x62>
    80004c08:	2244a783          	lw	a5,548(s1)
    80004c0c:	c385                	beqz	a5,80004c2c <piperead+0x62>
    if(pr->killed){
    80004c0e:	030a2783          	lw	a5,48(s4)
    80004c12:	ebc9                	bnez	a5,80004ca4 <piperead+0xda>
    sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
    80004c14:	85a6                	mv	a1,s1
    80004c16:	854e                	mv	a0,s3
    80004c18:	ffffd097          	auipc	ra,0xffffd
    80004c1c:	5aa080e7          	jalr	1450(ra) # 800021c2 <sleep>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80004c20:	2184a703          	lw	a4,536(s1)
    80004c24:	21c4a783          	lw	a5,540(s1)
    80004c28:	fef700e3          	beq	a4,a5,80004c08 <piperead+0x3e>
  }
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80004c2c:	4981                	li	s3,0
    if(pi->nread == pi->nwrite)
      break;
    ch = pi->data[pi->nread++ % PIPESIZE];
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80004c2e:	5b7d                	li	s6,-1
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80004c30:	05505463          	blez	s5,80004c78 <piperead+0xae>
    if(pi->nread == pi->nwrite)
    80004c34:	2184a783          	lw	a5,536(s1)
    80004c38:	21c4a703          	lw	a4,540(s1)
    80004c3c:	02f70e63          	beq	a4,a5,80004c78 <piperead+0xae>
    ch = pi->data[pi->nread++ % PIPESIZE];
    80004c40:	0017871b          	addiw	a4,a5,1
    80004c44:	20e4ac23          	sw	a4,536(s1)
    80004c48:	1ff7f793          	andi	a5,a5,511
    80004c4c:	97a6                	add	a5,a5,s1
    80004c4e:	0187c783          	lbu	a5,24(a5)
    80004c52:	faf40fa3          	sb	a5,-65(s0)
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80004c56:	4685                	li	a3,1
    80004c58:	fbf40613          	addi	a2,s0,-65
    80004c5c:	85ca                	mv	a1,s2
    80004c5e:	050a3503          	ld	a0,80(s4)
    80004c62:	ffffd097          	auipc	ra,0xffffd
    80004c66:	9e0080e7          	jalr	-1568(ra) # 80001642 <copyout>
    80004c6a:	01650763          	beq	a0,s6,80004c78 <piperead+0xae>
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80004c6e:	2985                	addiw	s3,s3,1
    80004c70:	0905                	addi	s2,s2,1
    80004c72:	fd3a91e3          	bne	s5,s3,80004c34 <piperead+0x6a>
    80004c76:	89d6                	mv	s3,s5
      break;
  }
  wakeup(&pi->nwrite);  //DOC: piperead-wakeup
    80004c78:	21c48513          	addi	a0,s1,540
    80004c7c:	ffffd097          	auipc	ra,0xffffd
    80004c80:	6c6080e7          	jalr	1734(ra) # 80002342 <wakeup>
  release(&pi->lock);
    80004c84:	8526                	mv	a0,s1
    80004c86:	ffffc097          	auipc	ra,0xffffc
    80004c8a:	ff0080e7          	jalr	-16(ra) # 80000c76 <release>
  return i;
}
    80004c8e:	854e                	mv	a0,s3
    80004c90:	60a6                	ld	ra,72(sp)
    80004c92:	6406                	ld	s0,64(sp)
    80004c94:	74e2                	ld	s1,56(sp)
    80004c96:	7942                	ld	s2,48(sp)
    80004c98:	79a2                	ld	s3,40(sp)
    80004c9a:	7a02                	ld	s4,32(sp)
    80004c9c:	6ae2                	ld	s5,24(sp)
    80004c9e:	6b42                	ld	s6,16(sp)
    80004ca0:	6161                	addi	sp,sp,80
    80004ca2:	8082                	ret
      release(&pi->lock);
    80004ca4:	8526                	mv	a0,s1
    80004ca6:	ffffc097          	auipc	ra,0xffffc
    80004caa:	fd0080e7          	jalr	-48(ra) # 80000c76 <release>
      return -1;
    80004cae:	59fd                	li	s3,-1
    80004cb0:	bff9                	j	80004c8e <piperead+0xc4>

0000000080004cb2 <exec>:

static int loadseg(pde_t *pgdir, uint64 addr, struct inode *ip, uint offset, uint sz);

int
exec(char *path, char **argv)
{
    80004cb2:	de010113          	addi	sp,sp,-544
    80004cb6:	20113c23          	sd	ra,536(sp)
    80004cba:	20813823          	sd	s0,528(sp)
    80004cbe:	20913423          	sd	s1,520(sp)
    80004cc2:	21213023          	sd	s2,512(sp)
    80004cc6:	ffce                	sd	s3,504(sp)
    80004cc8:	fbd2                	sd	s4,496(sp)
    80004cca:	f7d6                	sd	s5,488(sp)
    80004ccc:	f3da                	sd	s6,480(sp)
    80004cce:	efde                	sd	s7,472(sp)
    80004cd0:	ebe2                	sd	s8,464(sp)
    80004cd2:	e7e6                	sd	s9,456(sp)
    80004cd4:	e3ea                	sd	s10,448(sp)
    80004cd6:	ff6e                	sd	s11,440(sp)
    80004cd8:	1400                	addi	s0,sp,544
    80004cda:	892a                	mv	s2,a0
    80004cdc:	dea43423          	sd	a0,-536(s0)
    80004ce0:	deb43823          	sd	a1,-528(s0)
  uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
  struct elfhdr elf;
  struct inode *ip;
  struct proghdr ph;
  pagetable_t pagetable = 0, oldpagetable;
  struct proc *p = myproc();
    80004ce4:	ffffd097          	auipc	ra,0xffffd
    80004ce8:	cc6080e7          	jalr	-826(ra) # 800019aa <myproc>
    80004cec:	84aa                	mv	s1,a0

  begin_op();
    80004cee:	fffff097          	auipc	ra,0xfffff
    80004cf2:	4a0080e7          	jalr	1184(ra) # 8000418e <begin_op>

  if((ip = namei(path)) == 0){
    80004cf6:	854a                	mv	a0,s2
    80004cf8:	fffff097          	auipc	ra,0xfffff
    80004cfc:	276080e7          	jalr	630(ra) # 80003f6e <namei>
    80004d00:	c93d                	beqz	a0,80004d76 <exec+0xc4>
    80004d02:	8aaa                	mv	s5,a0
    end_op();
    return -1;
  }
  ilock(ip);
    80004d04:	fffff097          	auipc	ra,0xfffff
    80004d08:	9a0080e7          	jalr	-1632(ra) # 800036a4 <ilock>

  // Check ELF header
  if(readi(ip, 0, (uint64)&elf, 0, sizeof(elf)) != sizeof(elf))
    80004d0c:	04000713          	li	a4,64
    80004d10:	4681                	li	a3,0
    80004d12:	e4840613          	addi	a2,s0,-440
    80004d16:	4581                	li	a1,0
    80004d18:	8556                	mv	a0,s5
    80004d1a:	fffff097          	auipc	ra,0xfffff
    80004d1e:	ce4080e7          	jalr	-796(ra) # 800039fe <readi>
    80004d22:	04000793          	li	a5,64
    80004d26:	00f51a63          	bne	a0,a5,80004d3a <exec+0x88>
    goto bad;
  if(elf.magic != ELF_MAGIC)
    80004d2a:	e4842703          	lw	a4,-440(s0)
    80004d2e:	464c47b7          	lui	a5,0x464c4
    80004d32:	57f78793          	addi	a5,a5,1407 # 464c457f <_entry-0x39b3ba81>
    80004d36:	04f70663          	beq	a4,a5,80004d82 <exec+0xd0>

 bad:
  if(pagetable)
    proc_freepagetable(pagetable, sz);
  if(ip){
    iunlockput(ip);
    80004d3a:	8556                	mv	a0,s5
    80004d3c:	fffff097          	auipc	ra,0xfffff
    80004d40:	c70080e7          	jalr	-912(ra) # 800039ac <iunlockput>
    end_op();
    80004d44:	fffff097          	auipc	ra,0xfffff
    80004d48:	4c8080e7          	jalr	1224(ra) # 8000420c <end_op>
  }
  return -1;
    80004d4c:	557d                	li	a0,-1
}
    80004d4e:	21813083          	ld	ra,536(sp)
    80004d52:	21013403          	ld	s0,528(sp)
    80004d56:	20813483          	ld	s1,520(sp)
    80004d5a:	20013903          	ld	s2,512(sp)
    80004d5e:	79fe                	ld	s3,504(sp)
    80004d60:	7a5e                	ld	s4,496(sp)
    80004d62:	7abe                	ld	s5,488(sp)
    80004d64:	7b1e                	ld	s6,480(sp)
    80004d66:	6bfe                	ld	s7,472(sp)
    80004d68:	6c5e                	ld	s8,464(sp)
    80004d6a:	6cbe                	ld	s9,456(sp)
    80004d6c:	6d1e                	ld	s10,448(sp)
    80004d6e:	7dfa                	ld	s11,440(sp)
    80004d70:	22010113          	addi	sp,sp,544
    80004d74:	8082                	ret
    end_op();
    80004d76:	fffff097          	auipc	ra,0xfffff
    80004d7a:	496080e7          	jalr	1174(ra) # 8000420c <end_op>
    return -1;
    80004d7e:	557d                	li	a0,-1
    80004d80:	b7f9                	j	80004d4e <exec+0x9c>
  if((pagetable = proc_pagetable(p)) == 0)
    80004d82:	8526                	mv	a0,s1
    80004d84:	ffffd097          	auipc	ra,0xffffd
    80004d88:	cea080e7          	jalr	-790(ra) # 80001a6e <proc_pagetable>
    80004d8c:	8b2a                	mv	s6,a0
    80004d8e:	d555                	beqz	a0,80004d3a <exec+0x88>
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    80004d90:	e6842783          	lw	a5,-408(s0)
    80004d94:	e8045703          	lhu	a4,-384(s0)
    80004d98:	c735                	beqz	a4,80004e04 <exec+0x152>
  uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
    80004d9a:	4481                	li	s1,0
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    80004d9c:	e0043423          	sd	zero,-504(s0)
    if(ph.vaddr % PGSIZE != 0)
    80004da0:	6a05                	lui	s4,0x1
    80004da2:	fffa0713          	addi	a4,s4,-1 # fff <_entry-0x7ffff001>
    80004da6:	dee43023          	sd	a4,-544(s0)
  uint64 pa;

  if((va % PGSIZE) != 0)
    panic("loadseg: va must be page aligned");

  for(i = 0; i < sz; i += PGSIZE){
    80004daa:	6d85                	lui	s11,0x1
    80004dac:	7d7d                	lui	s10,0xfffff
    80004dae:	ac1d                	j	80004fe4 <exec+0x332>
    pa = walkaddr(pagetable, va + i);
    if(pa == 0)
      panic("loadseg: address should exist");
    80004db0:	00004517          	auipc	a0,0x4
    80004db4:	8f850513          	addi	a0,a0,-1800 # 800086a8 <syscalls+0x288>
    80004db8:	ffffb097          	auipc	ra,0xffffb
    80004dbc:	774080e7          	jalr	1908(ra) # 8000052c <panic>
    if(sz - i < PGSIZE)
      n = sz - i;
    else
      n = PGSIZE;
    if(readi(ip, 0, (uint64)pa, offset+i, n) != n)
    80004dc0:	874a                	mv	a4,s2
    80004dc2:	009c86bb          	addw	a3,s9,s1
    80004dc6:	4581                	li	a1,0
    80004dc8:	8556                	mv	a0,s5
    80004dca:	fffff097          	auipc	ra,0xfffff
    80004dce:	c34080e7          	jalr	-972(ra) # 800039fe <readi>
    80004dd2:	2501                	sext.w	a0,a0
    80004dd4:	1aa91863          	bne	s2,a0,80004f84 <exec+0x2d2>
  for(i = 0; i < sz; i += PGSIZE){
    80004dd8:	009d84bb          	addw	s1,s11,s1
    80004ddc:	013d09bb          	addw	s3,s10,s3
    80004de0:	1f74f263          	bgeu	s1,s7,80004fc4 <exec+0x312>
    pa = walkaddr(pagetable, va + i);
    80004de4:	02049593          	slli	a1,s1,0x20
    80004de8:	9181                	srli	a1,a1,0x20
    80004dea:	95e2                	add	a1,a1,s8
    80004dec:	855a                	mv	a0,s6
    80004dee:	ffffc097          	auipc	ra,0xffffc
    80004df2:	25e080e7          	jalr	606(ra) # 8000104c <walkaddr>
    80004df6:	862a                	mv	a2,a0
    if(pa == 0)
    80004df8:	dd45                	beqz	a0,80004db0 <exec+0xfe>
      n = PGSIZE;
    80004dfa:	8952                	mv	s2,s4
    if(sz - i < PGSIZE)
    80004dfc:	fd49f2e3          	bgeu	s3,s4,80004dc0 <exec+0x10e>
      n = sz - i;
    80004e00:	894e                	mv	s2,s3
    80004e02:	bf7d                	j	80004dc0 <exec+0x10e>
  uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
    80004e04:	4481                	li	s1,0
  iunlockput(ip);
    80004e06:	8556                	mv	a0,s5
    80004e08:	fffff097          	auipc	ra,0xfffff
    80004e0c:	ba4080e7          	jalr	-1116(ra) # 800039ac <iunlockput>
  end_op();
    80004e10:	fffff097          	auipc	ra,0xfffff
    80004e14:	3fc080e7          	jalr	1020(ra) # 8000420c <end_op>
  p = myproc();
    80004e18:	ffffd097          	auipc	ra,0xffffd
    80004e1c:	b92080e7          	jalr	-1134(ra) # 800019aa <myproc>
    80004e20:	8baa                	mv	s7,a0
  uint64 oldsz = p->sz;
    80004e22:	04853d03          	ld	s10,72(a0)
  sz = PGROUNDUP(sz);
    80004e26:	6785                	lui	a5,0x1
    80004e28:	17fd                	addi	a5,a5,-1 # fff <_entry-0x7ffff001>
    80004e2a:	97a6                	add	a5,a5,s1
    80004e2c:	777d                	lui	a4,0xfffff
    80004e2e:	8ff9                	and	a5,a5,a4
    80004e30:	def43c23          	sd	a5,-520(s0)
  if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    80004e34:	6609                	lui	a2,0x2
    80004e36:	963e                	add	a2,a2,a5
    80004e38:	85be                	mv	a1,a5
    80004e3a:	855a                	mv	a0,s6
    80004e3c:	ffffc097          	auipc	ra,0xffffc
    80004e40:	5b2080e7          	jalr	1458(ra) # 800013ee <uvmalloc>
    80004e44:	8c2a                	mv	s8,a0
  ip = 0;
    80004e46:	4a81                	li	s5,0
  if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    80004e48:	12050e63          	beqz	a0,80004f84 <exec+0x2d2>
  uvmclear(pagetable, sz-2*PGSIZE);
    80004e4c:	75f9                	lui	a1,0xffffe
    80004e4e:	95aa                	add	a1,a1,a0
    80004e50:	855a                	mv	a0,s6
    80004e52:	ffffc097          	auipc	ra,0xffffc
    80004e56:	7be080e7          	jalr	1982(ra) # 80001610 <uvmclear>
  stackbase = sp - PGSIZE;
    80004e5a:	7afd                	lui	s5,0xfffff
    80004e5c:	9ae2                	add	s5,s5,s8
  for(argc = 0; argv[argc]; argc++) {
    80004e5e:	df043783          	ld	a5,-528(s0)
    80004e62:	6388                	ld	a0,0(a5)
    80004e64:	c925                	beqz	a0,80004ed4 <exec+0x222>
    80004e66:	e8840993          	addi	s3,s0,-376
    80004e6a:	f8840c93          	addi	s9,s0,-120
  sp = sz;
    80004e6e:	8962                	mv	s2,s8
  for(argc = 0; argv[argc]; argc++) {
    80004e70:	4481                	li	s1,0
    sp -= strlen(argv[argc]) + 1;
    80004e72:	ffffc097          	auipc	ra,0xffffc
    80004e76:	fd0080e7          	jalr	-48(ra) # 80000e42 <strlen>
    80004e7a:	0015079b          	addiw	a5,a0,1
    80004e7e:	40f907b3          	sub	a5,s2,a5
    sp -= sp % 16; // riscv sp must be 16-byte aligned
    80004e82:	ff07f913          	andi	s2,a5,-16
    if(sp < stackbase)
    80004e86:	13596363          	bltu	s2,s5,80004fac <exec+0x2fa>
    if(copyout(pagetable, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
    80004e8a:	df043d83          	ld	s11,-528(s0)
    80004e8e:	000dba03          	ld	s4,0(s11) # 1000 <_entry-0x7ffff000>
    80004e92:	8552                	mv	a0,s4
    80004e94:	ffffc097          	auipc	ra,0xffffc
    80004e98:	fae080e7          	jalr	-82(ra) # 80000e42 <strlen>
    80004e9c:	0015069b          	addiw	a3,a0,1
    80004ea0:	8652                	mv	a2,s4
    80004ea2:	85ca                	mv	a1,s2
    80004ea4:	855a                	mv	a0,s6
    80004ea6:	ffffc097          	auipc	ra,0xffffc
    80004eaa:	79c080e7          	jalr	1948(ra) # 80001642 <copyout>
    80004eae:	10054363          	bltz	a0,80004fb4 <exec+0x302>
    ustack[argc] = sp;
    80004eb2:	0129b023          	sd	s2,0(s3)
  for(argc = 0; argv[argc]; argc++) {
    80004eb6:	0485                	addi	s1,s1,1
    80004eb8:	008d8793          	addi	a5,s11,8
    80004ebc:	def43823          	sd	a5,-528(s0)
    80004ec0:	008db503          	ld	a0,8(s11)
    80004ec4:	c911                	beqz	a0,80004ed8 <exec+0x226>
    if(argc >= MAXARG)
    80004ec6:	09a1                	addi	s3,s3,8
    80004ec8:	fb3c95e3          	bne	s9,s3,80004e72 <exec+0x1c0>
  sz = sz1;
    80004ecc:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    80004ed0:	4a81                	li	s5,0
    80004ed2:	a84d                	j	80004f84 <exec+0x2d2>
  sp = sz;
    80004ed4:	8962                	mv	s2,s8
  for(argc = 0; argv[argc]; argc++) {
    80004ed6:	4481                	li	s1,0
  ustack[argc] = 0;
    80004ed8:	00349793          	slli	a5,s1,0x3
    80004edc:	f9078793          	addi	a5,a5,-112
    80004ee0:	97a2                	add	a5,a5,s0
    80004ee2:	ee07bc23          	sd	zero,-264(a5)
  sp -= (argc+1) * sizeof(uint64);
    80004ee6:	00148693          	addi	a3,s1,1
    80004eea:	068e                	slli	a3,a3,0x3
    80004eec:	40d90933          	sub	s2,s2,a3
  sp -= sp % 16;
    80004ef0:	ff097913          	andi	s2,s2,-16
  if(sp < stackbase)
    80004ef4:	01597663          	bgeu	s2,s5,80004f00 <exec+0x24e>
  sz = sz1;
    80004ef8:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    80004efc:	4a81                	li	s5,0
    80004efe:	a059                	j	80004f84 <exec+0x2d2>
  if(copyout(pagetable, sp, (char *)ustack, (argc+1)*sizeof(uint64)) < 0)
    80004f00:	e8840613          	addi	a2,s0,-376
    80004f04:	85ca                	mv	a1,s2
    80004f06:	855a                	mv	a0,s6
    80004f08:	ffffc097          	auipc	ra,0xffffc
    80004f0c:	73a080e7          	jalr	1850(ra) # 80001642 <copyout>
    80004f10:	0a054663          	bltz	a0,80004fbc <exec+0x30a>
  p->trapframe->a1 = sp;
    80004f14:	058bb783          	ld	a5,88(s7)
    80004f18:	0727bc23          	sd	s2,120(a5)
  for(last=s=path; *s; s++)
    80004f1c:	de843783          	ld	a5,-536(s0)
    80004f20:	0007c703          	lbu	a4,0(a5)
    80004f24:	cf11                	beqz	a4,80004f40 <exec+0x28e>
    80004f26:	0785                	addi	a5,a5,1
    if(*s == '/')
    80004f28:	02f00693          	li	a3,47
    80004f2c:	a039                	j	80004f3a <exec+0x288>
      last = s+1;
    80004f2e:	def43423          	sd	a5,-536(s0)
  for(last=s=path; *s; s++)
    80004f32:	0785                	addi	a5,a5,1
    80004f34:	fff7c703          	lbu	a4,-1(a5)
    80004f38:	c701                	beqz	a4,80004f40 <exec+0x28e>
    if(*s == '/')
    80004f3a:	fed71ce3          	bne	a4,a3,80004f32 <exec+0x280>
    80004f3e:	bfc5                	j	80004f2e <exec+0x27c>
  safestrcpy(p->name, last, sizeof(p->name));
    80004f40:	4641                	li	a2,16
    80004f42:	de843583          	ld	a1,-536(s0)
    80004f46:	158b8513          	addi	a0,s7,344
    80004f4a:	ffffc097          	auipc	ra,0xffffc
    80004f4e:	ec6080e7          	jalr	-314(ra) # 80000e10 <safestrcpy>
  oldpagetable = p->pagetable;
    80004f52:	050bb503          	ld	a0,80(s7)
  p->pagetable = pagetable;
    80004f56:	056bb823          	sd	s6,80(s7)
  p->sz = sz;
    80004f5a:	058bb423          	sd	s8,72(s7)
  p->trapframe->epc = elf.entry;  // initial program counter = main
    80004f5e:	058bb783          	ld	a5,88(s7)
    80004f62:	e6043703          	ld	a4,-416(s0)
    80004f66:	ef98                	sd	a4,24(a5)
  p->trapframe->sp = sp; // initial stack pointer
    80004f68:	058bb783          	ld	a5,88(s7)
    80004f6c:	0327b823          	sd	s2,48(a5)
  proc_freepagetable(oldpagetable, oldsz);
    80004f70:	85ea                	mv	a1,s10
    80004f72:	ffffd097          	auipc	ra,0xffffd
    80004f76:	b98080e7          	jalr	-1128(ra) # 80001b0a <proc_freepagetable>
  return argc; // this ends up in a0, the first argument to main(argc, argv)
    80004f7a:	0004851b          	sext.w	a0,s1
    80004f7e:	bbc1                	j	80004d4e <exec+0x9c>
    80004f80:	de943c23          	sd	s1,-520(s0)
    proc_freepagetable(pagetable, sz);
    80004f84:	df843583          	ld	a1,-520(s0)
    80004f88:	855a                	mv	a0,s6
    80004f8a:	ffffd097          	auipc	ra,0xffffd
    80004f8e:	b80080e7          	jalr	-1152(ra) # 80001b0a <proc_freepagetable>
  if(ip){
    80004f92:	da0a94e3          	bnez	s5,80004d3a <exec+0x88>
  return -1;
    80004f96:	557d                	li	a0,-1
    80004f98:	bb5d                	j	80004d4e <exec+0x9c>
    80004f9a:	de943c23          	sd	s1,-520(s0)
    80004f9e:	b7dd                	j	80004f84 <exec+0x2d2>
    80004fa0:	de943c23          	sd	s1,-520(s0)
    80004fa4:	b7c5                	j	80004f84 <exec+0x2d2>
    80004fa6:	de943c23          	sd	s1,-520(s0)
    80004faa:	bfe9                	j	80004f84 <exec+0x2d2>
  sz = sz1;
    80004fac:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    80004fb0:	4a81                	li	s5,0
    80004fb2:	bfc9                	j	80004f84 <exec+0x2d2>
  sz = sz1;
    80004fb4:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    80004fb8:	4a81                	li	s5,0
    80004fba:	b7e9                	j	80004f84 <exec+0x2d2>
  sz = sz1;
    80004fbc:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    80004fc0:	4a81                	li	s5,0
    80004fc2:	b7c9                	j	80004f84 <exec+0x2d2>
    if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
    80004fc4:	df843483          	ld	s1,-520(s0)
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    80004fc8:	e0843783          	ld	a5,-504(s0)
    80004fcc:	0017869b          	addiw	a3,a5,1
    80004fd0:	e0d43423          	sd	a3,-504(s0)
    80004fd4:	e0043783          	ld	a5,-512(s0)
    80004fd8:	0387879b          	addiw	a5,a5,56
    80004fdc:	e8045703          	lhu	a4,-384(s0)
    80004fe0:	e2e6d3e3          	bge	a3,a4,80004e06 <exec+0x154>
    if(readi(ip, 0, (uint64)&ph, off, sizeof(ph)) != sizeof(ph))
    80004fe4:	2781                	sext.w	a5,a5
    80004fe6:	e0f43023          	sd	a5,-512(s0)
    80004fea:	03800713          	li	a4,56
    80004fee:	86be                	mv	a3,a5
    80004ff0:	e1040613          	addi	a2,s0,-496
    80004ff4:	4581                	li	a1,0
    80004ff6:	8556                	mv	a0,s5
    80004ff8:	fffff097          	auipc	ra,0xfffff
    80004ffc:	a06080e7          	jalr	-1530(ra) # 800039fe <readi>
    80005000:	03800793          	li	a5,56
    80005004:	f6f51ee3          	bne	a0,a5,80004f80 <exec+0x2ce>
    if(ph.type != ELF_PROG_LOAD)
    80005008:	e1042783          	lw	a5,-496(s0)
    8000500c:	4705                	li	a4,1
    8000500e:	fae79de3          	bne	a5,a4,80004fc8 <exec+0x316>
    if(ph.memsz < ph.filesz)
    80005012:	e3843603          	ld	a2,-456(s0)
    80005016:	e3043783          	ld	a5,-464(s0)
    8000501a:	f8f660e3          	bltu	a2,a5,80004f9a <exec+0x2e8>
    if(ph.vaddr + ph.memsz < ph.vaddr)
    8000501e:	e2043783          	ld	a5,-480(s0)
    80005022:	963e                	add	a2,a2,a5
    80005024:	f6f66ee3          	bltu	a2,a5,80004fa0 <exec+0x2ee>
    if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
    80005028:	85a6                	mv	a1,s1
    8000502a:	855a                	mv	a0,s6
    8000502c:	ffffc097          	auipc	ra,0xffffc
    80005030:	3c2080e7          	jalr	962(ra) # 800013ee <uvmalloc>
    80005034:	dea43c23          	sd	a0,-520(s0)
    80005038:	d53d                	beqz	a0,80004fa6 <exec+0x2f4>
    if(ph.vaddr % PGSIZE != 0)
    8000503a:	e2043c03          	ld	s8,-480(s0)
    8000503e:	de043783          	ld	a5,-544(s0)
    80005042:	00fc77b3          	and	a5,s8,a5
    80005046:	ff9d                	bnez	a5,80004f84 <exec+0x2d2>
    if(loadseg(pagetable, ph.vaddr, ip, ph.off, ph.filesz) < 0)
    80005048:	e1842c83          	lw	s9,-488(s0)
    8000504c:	e3042b83          	lw	s7,-464(s0)
  for(i = 0; i < sz; i += PGSIZE){
    80005050:	f60b8ae3          	beqz	s7,80004fc4 <exec+0x312>
    80005054:	89de                	mv	s3,s7
    80005056:	4481                	li	s1,0
    80005058:	b371                	j	80004de4 <exec+0x132>

000000008000505a <argfd>:

// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
static int
argfd(int n, int *pfd, struct file **pf)
{
    8000505a:	7179                	addi	sp,sp,-48
    8000505c:	f406                	sd	ra,40(sp)
    8000505e:	f022                	sd	s0,32(sp)
    80005060:	ec26                	sd	s1,24(sp)
    80005062:	e84a                	sd	s2,16(sp)
    80005064:	1800                	addi	s0,sp,48
    80005066:	892e                	mv	s2,a1
    80005068:	84b2                	mv	s1,a2
  int fd;
  struct file *f;

  if(argint(n, &fd) < 0)
    8000506a:	fdc40593          	addi	a1,s0,-36
    8000506e:	ffffe097          	auipc	ra,0xffffe
    80005072:	9fc080e7          	jalr	-1540(ra) # 80002a6a <argint>
    80005076:	04054063          	bltz	a0,800050b6 <argfd+0x5c>
    return -1;
  if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
    8000507a:	fdc42703          	lw	a4,-36(s0)
    8000507e:	47bd                	li	a5,15
    80005080:	02e7ed63          	bltu	a5,a4,800050ba <argfd+0x60>
    80005084:	ffffd097          	auipc	ra,0xffffd
    80005088:	926080e7          	jalr	-1754(ra) # 800019aa <myproc>
    8000508c:	fdc42703          	lw	a4,-36(s0)
    80005090:	01a70793          	addi	a5,a4,26 # fffffffffffff01a <end+0xffffffff7ffde01a>
    80005094:	078e                	slli	a5,a5,0x3
    80005096:	953e                	add	a0,a0,a5
    80005098:	611c                	ld	a5,0(a0)
    8000509a:	c395                	beqz	a5,800050be <argfd+0x64>
    return -1;
  if(pfd)
    8000509c:	00090463          	beqz	s2,800050a4 <argfd+0x4a>
    *pfd = fd;
    800050a0:	00e92023          	sw	a4,0(s2)
  if(pf)
    *pf = f;
  return 0;
    800050a4:	4501                	li	a0,0
  if(pf)
    800050a6:	c091                	beqz	s1,800050aa <argfd+0x50>
    *pf = f;
    800050a8:	e09c                	sd	a5,0(s1)
}
    800050aa:	70a2                	ld	ra,40(sp)
    800050ac:	7402                	ld	s0,32(sp)
    800050ae:	64e2                	ld	s1,24(sp)
    800050b0:	6942                	ld	s2,16(sp)
    800050b2:	6145                	addi	sp,sp,48
    800050b4:	8082                	ret
    return -1;
    800050b6:	557d                	li	a0,-1
    800050b8:	bfcd                	j	800050aa <argfd+0x50>
    return -1;
    800050ba:	557d                	li	a0,-1
    800050bc:	b7fd                	j	800050aa <argfd+0x50>
    800050be:	557d                	li	a0,-1
    800050c0:	b7ed                	j	800050aa <argfd+0x50>

00000000800050c2 <fdalloc>:

// Allocate a file descriptor for the given file.
// Takes over file reference from caller on success.
static int
fdalloc(struct file *f)
{
    800050c2:	1101                	addi	sp,sp,-32
    800050c4:	ec06                	sd	ra,24(sp)
    800050c6:	e822                	sd	s0,16(sp)
    800050c8:	e426                	sd	s1,8(sp)
    800050ca:	1000                	addi	s0,sp,32
    800050cc:	84aa                	mv	s1,a0
  int fd;
  struct proc *p = myproc();
    800050ce:	ffffd097          	auipc	ra,0xffffd
    800050d2:	8dc080e7          	jalr	-1828(ra) # 800019aa <myproc>
    800050d6:	862a                	mv	a2,a0

  for(fd = 0; fd < NOFILE; fd++){
    800050d8:	0d050793          	addi	a5,a0,208
    800050dc:	4501                	li	a0,0
    800050de:	46c1                	li	a3,16
    if(p->ofile[fd] == 0){
    800050e0:	6398                	ld	a4,0(a5)
    800050e2:	cb19                	beqz	a4,800050f8 <fdalloc+0x36>
  for(fd = 0; fd < NOFILE; fd++){
    800050e4:	2505                	addiw	a0,a0,1
    800050e6:	07a1                	addi	a5,a5,8
    800050e8:	fed51ce3          	bne	a0,a3,800050e0 <fdalloc+0x1e>
      p->ofile[fd] = f;
      return fd;
    }
  }
  return -1;
    800050ec:	557d                	li	a0,-1
}
    800050ee:	60e2                	ld	ra,24(sp)
    800050f0:	6442                	ld	s0,16(sp)
    800050f2:	64a2                	ld	s1,8(sp)
    800050f4:	6105                	addi	sp,sp,32
    800050f6:	8082                	ret
      p->ofile[fd] = f;
    800050f8:	01a50793          	addi	a5,a0,26
    800050fc:	078e                	slli	a5,a5,0x3
    800050fe:	963e                	add	a2,a2,a5
    80005100:	e204                	sd	s1,0(a2)
      return fd;
    80005102:	b7f5                	j	800050ee <fdalloc+0x2c>

0000000080005104 <create>:
  return -1;
}

static struct inode*
create(char *path, short type, short major, short minor)
{
    80005104:	715d                	addi	sp,sp,-80
    80005106:	e486                	sd	ra,72(sp)
    80005108:	e0a2                	sd	s0,64(sp)
    8000510a:	fc26                	sd	s1,56(sp)
    8000510c:	f84a                	sd	s2,48(sp)
    8000510e:	f44e                	sd	s3,40(sp)
    80005110:	f052                	sd	s4,32(sp)
    80005112:	ec56                	sd	s5,24(sp)
    80005114:	0880                	addi	s0,sp,80
    80005116:	89ae                	mv	s3,a1
    80005118:	8ab2                	mv	s5,a2
    8000511a:	8a36                	mv	s4,a3
  struct inode *ip, *dp;
  char name[DIRSIZ];

  if((dp = nameiparent(path, name)) == 0)
    8000511c:	fb040593          	addi	a1,s0,-80
    80005120:	fffff097          	auipc	ra,0xfffff
    80005124:	e6c080e7          	jalr	-404(ra) # 80003f8c <nameiparent>
    80005128:	892a                	mv	s2,a0
    8000512a:	12050e63          	beqz	a0,80005266 <create+0x162>
    return 0;

  ilock(dp);
    8000512e:	ffffe097          	auipc	ra,0xffffe
    80005132:	576080e7          	jalr	1398(ra) # 800036a4 <ilock>

  if((ip = dirlookup(dp, name, 0)) != 0){
    80005136:	4601                	li	a2,0
    80005138:	fb040593          	addi	a1,s0,-80
    8000513c:	854a                	mv	a0,s2
    8000513e:	fffff097          	auipc	ra,0xfffff
    80005142:	b58080e7          	jalr	-1192(ra) # 80003c96 <dirlookup>
    80005146:	84aa                	mv	s1,a0
    80005148:	c921                	beqz	a0,80005198 <create+0x94>
    iunlockput(dp);
    8000514a:	854a                	mv	a0,s2
    8000514c:	fffff097          	auipc	ra,0xfffff
    80005150:	860080e7          	jalr	-1952(ra) # 800039ac <iunlockput>
    ilock(ip);
    80005154:	8526                	mv	a0,s1
    80005156:	ffffe097          	auipc	ra,0xffffe
    8000515a:	54e080e7          	jalr	1358(ra) # 800036a4 <ilock>
    if(type == T_FILE && (ip->type == T_FILE || ip->type == T_DEVICE))
    8000515e:	2981                	sext.w	s3,s3
    80005160:	4789                	li	a5,2
    80005162:	02f99463          	bne	s3,a5,8000518a <create+0x86>
    80005166:	0444d783          	lhu	a5,68(s1)
    8000516a:	37f9                	addiw	a5,a5,-2
    8000516c:	17c2                	slli	a5,a5,0x30
    8000516e:	93c1                	srli	a5,a5,0x30
    80005170:	4705                	li	a4,1
    80005172:	00f76c63          	bltu	a4,a5,8000518a <create+0x86>
    panic("create: dirlink");

  iunlockput(dp);

  return ip;
}
    80005176:	8526                	mv	a0,s1
    80005178:	60a6                	ld	ra,72(sp)
    8000517a:	6406                	ld	s0,64(sp)
    8000517c:	74e2                	ld	s1,56(sp)
    8000517e:	7942                	ld	s2,48(sp)
    80005180:	79a2                	ld	s3,40(sp)
    80005182:	7a02                	ld	s4,32(sp)
    80005184:	6ae2                	ld	s5,24(sp)
    80005186:	6161                	addi	sp,sp,80
    80005188:	8082                	ret
    iunlockput(ip);
    8000518a:	8526                	mv	a0,s1
    8000518c:	fffff097          	auipc	ra,0xfffff
    80005190:	820080e7          	jalr	-2016(ra) # 800039ac <iunlockput>
    return 0;
    80005194:	4481                	li	s1,0
    80005196:	b7c5                	j	80005176 <create+0x72>
  if((ip = ialloc(dp->dev, type)) == 0)
    80005198:	85ce                	mv	a1,s3
    8000519a:	00092503          	lw	a0,0(s2)
    8000519e:	ffffe097          	auipc	ra,0xffffe
    800051a2:	36c080e7          	jalr	876(ra) # 8000350a <ialloc>
    800051a6:	84aa                	mv	s1,a0
    800051a8:	c521                	beqz	a0,800051f0 <create+0xec>
  ilock(ip);
    800051aa:	ffffe097          	auipc	ra,0xffffe
    800051ae:	4fa080e7          	jalr	1274(ra) # 800036a4 <ilock>
  ip->major = major;
    800051b2:	05549323          	sh	s5,70(s1)
  ip->minor = minor;
    800051b6:	05449423          	sh	s4,72(s1)
  ip->nlink = 1;
    800051ba:	4a05                	li	s4,1
    800051bc:	05449523          	sh	s4,74(s1)
  iupdate(ip);
    800051c0:	8526                	mv	a0,s1
    800051c2:	ffffe097          	auipc	ra,0xffffe
    800051c6:	416080e7          	jalr	1046(ra) # 800035d8 <iupdate>
  if(type == T_DIR){  // Create . and .. entries.
    800051ca:	2981                	sext.w	s3,s3
    800051cc:	03498a63          	beq	s3,s4,80005200 <create+0xfc>
  if(dirlink(dp, name, ip->inum) < 0)
    800051d0:	40d0                	lw	a2,4(s1)
    800051d2:	fb040593          	addi	a1,s0,-80
    800051d6:	854a                	mv	a0,s2
    800051d8:	fffff097          	auipc	ra,0xfffff
    800051dc:	cd4080e7          	jalr	-812(ra) # 80003eac <dirlink>
    800051e0:	06054b63          	bltz	a0,80005256 <create+0x152>
  iunlockput(dp);
    800051e4:	854a                	mv	a0,s2
    800051e6:	ffffe097          	auipc	ra,0xffffe
    800051ea:	7c6080e7          	jalr	1990(ra) # 800039ac <iunlockput>
  return ip;
    800051ee:	b761                	j	80005176 <create+0x72>
    panic("create: ialloc");
    800051f0:	00003517          	auipc	a0,0x3
    800051f4:	4d850513          	addi	a0,a0,1240 # 800086c8 <syscalls+0x2a8>
    800051f8:	ffffb097          	auipc	ra,0xffffb
    800051fc:	334080e7          	jalr	820(ra) # 8000052c <panic>
    dp->nlink++;  // for ".."
    80005200:	04a95783          	lhu	a5,74(s2)
    80005204:	2785                	addiw	a5,a5,1
    80005206:	04f91523          	sh	a5,74(s2)
    iupdate(dp);
    8000520a:	854a                	mv	a0,s2
    8000520c:	ffffe097          	auipc	ra,0xffffe
    80005210:	3cc080e7          	jalr	972(ra) # 800035d8 <iupdate>
    if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
    80005214:	40d0                	lw	a2,4(s1)
    80005216:	00003597          	auipc	a1,0x3
    8000521a:	4c258593          	addi	a1,a1,1218 # 800086d8 <syscalls+0x2b8>
    8000521e:	8526                	mv	a0,s1
    80005220:	fffff097          	auipc	ra,0xfffff
    80005224:	c8c080e7          	jalr	-884(ra) # 80003eac <dirlink>
    80005228:	00054f63          	bltz	a0,80005246 <create+0x142>
    8000522c:	00492603          	lw	a2,4(s2)
    80005230:	00003597          	auipc	a1,0x3
    80005234:	4b058593          	addi	a1,a1,1200 # 800086e0 <syscalls+0x2c0>
    80005238:	8526                	mv	a0,s1
    8000523a:	fffff097          	auipc	ra,0xfffff
    8000523e:	c72080e7          	jalr	-910(ra) # 80003eac <dirlink>
    80005242:	f80557e3          	bgez	a0,800051d0 <create+0xcc>
      panic("create dots");
    80005246:	00003517          	auipc	a0,0x3
    8000524a:	4a250513          	addi	a0,a0,1186 # 800086e8 <syscalls+0x2c8>
    8000524e:	ffffb097          	auipc	ra,0xffffb
    80005252:	2de080e7          	jalr	734(ra) # 8000052c <panic>
    panic("create: dirlink");
    80005256:	00003517          	auipc	a0,0x3
    8000525a:	4a250513          	addi	a0,a0,1186 # 800086f8 <syscalls+0x2d8>
    8000525e:	ffffb097          	auipc	ra,0xffffb
    80005262:	2ce080e7          	jalr	718(ra) # 8000052c <panic>
    return 0;
    80005266:	84aa                	mv	s1,a0
    80005268:	b739                	j	80005176 <create+0x72>

000000008000526a <sys_dup>:
{
    8000526a:	7179                	addi	sp,sp,-48
    8000526c:	f406                	sd	ra,40(sp)
    8000526e:	f022                	sd	s0,32(sp)
    80005270:	ec26                	sd	s1,24(sp)
    80005272:	e84a                	sd	s2,16(sp)
    80005274:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0)
    80005276:	fd840613          	addi	a2,s0,-40
    8000527a:	4581                	li	a1,0
    8000527c:	4501                	li	a0,0
    8000527e:	00000097          	auipc	ra,0x0
    80005282:	ddc080e7          	jalr	-548(ra) # 8000505a <argfd>
    return -1;
    80005286:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0)
    80005288:	02054363          	bltz	a0,800052ae <sys_dup+0x44>
  if((fd=fdalloc(f)) < 0)
    8000528c:	fd843903          	ld	s2,-40(s0)
    80005290:	854a                	mv	a0,s2
    80005292:	00000097          	auipc	ra,0x0
    80005296:	e30080e7          	jalr	-464(ra) # 800050c2 <fdalloc>
    8000529a:	84aa                	mv	s1,a0
    return -1;
    8000529c:	57fd                	li	a5,-1
  if((fd=fdalloc(f)) < 0)
    8000529e:	00054863          	bltz	a0,800052ae <sys_dup+0x44>
  filedup(f);
    800052a2:	854a                	mv	a0,s2
    800052a4:	fffff097          	auipc	ra,0xfffff
    800052a8:	368080e7          	jalr	872(ra) # 8000460c <filedup>
  return fd;
    800052ac:	87a6                	mv	a5,s1
}
    800052ae:	853e                	mv	a0,a5
    800052b0:	70a2                	ld	ra,40(sp)
    800052b2:	7402                	ld	s0,32(sp)
    800052b4:	64e2                	ld	s1,24(sp)
    800052b6:	6942                	ld	s2,16(sp)
    800052b8:	6145                	addi	sp,sp,48
    800052ba:	8082                	ret

00000000800052bc <sys_read>:
{
    800052bc:	7179                	addi	sp,sp,-48
    800052be:	f406                	sd	ra,40(sp)
    800052c0:	f022                	sd	s0,32(sp)
    800052c2:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800052c4:	fe840613          	addi	a2,s0,-24
    800052c8:	4581                	li	a1,0
    800052ca:	4501                	li	a0,0
    800052cc:	00000097          	auipc	ra,0x0
    800052d0:	d8e080e7          	jalr	-626(ra) # 8000505a <argfd>
    return -1;
    800052d4:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800052d6:	04054163          	bltz	a0,80005318 <sys_read+0x5c>
    800052da:	fe440593          	addi	a1,s0,-28
    800052de:	4509                	li	a0,2
    800052e0:	ffffd097          	auipc	ra,0xffffd
    800052e4:	78a080e7          	jalr	1930(ra) # 80002a6a <argint>
    return -1;
    800052e8:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800052ea:	02054763          	bltz	a0,80005318 <sys_read+0x5c>
    800052ee:	fd840593          	addi	a1,s0,-40
    800052f2:	4505                	li	a0,1
    800052f4:	ffffd097          	auipc	ra,0xffffd
    800052f8:	798080e7          	jalr	1944(ra) # 80002a8c <argaddr>
    return -1;
    800052fc:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800052fe:	00054d63          	bltz	a0,80005318 <sys_read+0x5c>
  return fileread(f, p, n);
    80005302:	fe442603          	lw	a2,-28(s0)
    80005306:	fd843583          	ld	a1,-40(s0)
    8000530a:	fe843503          	ld	a0,-24(s0)
    8000530e:	fffff097          	auipc	ra,0xfffff
    80005312:	48a080e7          	jalr	1162(ra) # 80004798 <fileread>
    80005316:	87aa                	mv	a5,a0
}
    80005318:	853e                	mv	a0,a5
    8000531a:	70a2                	ld	ra,40(sp)
    8000531c:	7402                	ld	s0,32(sp)
    8000531e:	6145                	addi	sp,sp,48
    80005320:	8082                	ret

0000000080005322 <sys_write>:
{
    80005322:	7179                	addi	sp,sp,-48
    80005324:	f406                	sd	ra,40(sp)
    80005326:	f022                	sd	s0,32(sp)
    80005328:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    8000532a:	fe840613          	addi	a2,s0,-24
    8000532e:	4581                	li	a1,0
    80005330:	4501                	li	a0,0
    80005332:	00000097          	auipc	ra,0x0
    80005336:	d28080e7          	jalr	-728(ra) # 8000505a <argfd>
    return -1;
    8000533a:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    8000533c:	04054163          	bltz	a0,8000537e <sys_write+0x5c>
    80005340:	fe440593          	addi	a1,s0,-28
    80005344:	4509                	li	a0,2
    80005346:	ffffd097          	auipc	ra,0xffffd
    8000534a:	724080e7          	jalr	1828(ra) # 80002a6a <argint>
    return -1;
    8000534e:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005350:	02054763          	bltz	a0,8000537e <sys_write+0x5c>
    80005354:	fd840593          	addi	a1,s0,-40
    80005358:	4505                	li	a0,1
    8000535a:	ffffd097          	auipc	ra,0xffffd
    8000535e:	732080e7          	jalr	1842(ra) # 80002a8c <argaddr>
    return -1;
    80005362:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005364:	00054d63          	bltz	a0,8000537e <sys_write+0x5c>
  return filewrite(f, p, n);
    80005368:	fe442603          	lw	a2,-28(s0)
    8000536c:	fd843583          	ld	a1,-40(s0)
    80005370:	fe843503          	ld	a0,-24(s0)
    80005374:	fffff097          	auipc	ra,0xfffff
    80005378:	4e6080e7          	jalr	1254(ra) # 8000485a <filewrite>
    8000537c:	87aa                	mv	a5,a0
}
    8000537e:	853e                	mv	a0,a5
    80005380:	70a2                	ld	ra,40(sp)
    80005382:	7402                	ld	s0,32(sp)
    80005384:	6145                	addi	sp,sp,48
    80005386:	8082                	ret

0000000080005388 <sys_rbtn>:
{
    80005388:	7179                	addi	sp,sp,-48
    8000538a:	f406                	sd	ra,40(sp)
    8000538c:	f022                	sd	s0,32(sp)
    8000538e:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    80005390:	fe840613          	addi	a2,s0,-24
    80005394:	4581                	li	a1,0
    80005396:	4501                	li	a0,0
    80005398:	00000097          	auipc	ra,0x0
    8000539c:	cc2080e7          	jalr	-830(ra) # 8000505a <argfd>
    return -1;
    800053a0:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    800053a2:	04054f63          	bltz	a0,80005400 <sys_rbtn+0x78>
    800053a6:	fe440593          	addi	a1,s0,-28
    800053aa:	4509                	li	a0,2
    800053ac:	ffffd097          	auipc	ra,0xffffd
    800053b0:	6be080e7          	jalr	1726(ra) # 80002a6a <argint>
    return -1;
    800053b4:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    800053b6:	04054563          	bltz	a0,80005400 <sys_rbtn+0x78>
    800053ba:	fe040593          	addi	a1,s0,-32
    800053be:	450d                	li	a0,3
    800053c0:	ffffd097          	auipc	ra,0xffffd
    800053c4:	6aa080e7          	jalr	1706(ra) # 80002a6a <argint>
    return -1;
    800053c8:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    800053ca:	02054b63          	bltz	a0,80005400 <sys_rbtn+0x78>
    800053ce:	fd840593          	addi	a1,s0,-40
    800053d2:	4505                	li	a0,1
    800053d4:	ffffd097          	auipc	ra,0xffffd
    800053d8:	6b8080e7          	jalr	1720(ra) # 80002a8c <argaddr>
    return -1;
    800053dc:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    800053de:	02054163          	bltz	a0,80005400 <sys_rbtn+0x78>
  return rbtn(f->ip, 1, p, n, block);
    800053e2:	fe042703          	lw	a4,-32(s0)
    800053e6:	fe442683          	lw	a3,-28(s0)
    800053ea:	fd843603          	ld	a2,-40(s0)
    800053ee:	4585                	li	a1,1
    800053f0:	fe843783          	ld	a5,-24(s0)
    800053f4:	6f88                	ld	a0,24(a5)
    800053f6:	fffff097          	auipc	ra,0xfffff
    800053fa:	83a080e7          	jalr	-1990(ra) # 80003c30 <rbtn>
    800053fe:	87aa                	mv	a5,a0
}
    80005400:	853e                	mv	a0,a5
    80005402:	70a2                	ld	ra,40(sp)
    80005404:	7402                	ld	s0,32(sp)
    80005406:	6145                	addi	sp,sp,48
    80005408:	8082                	ret

000000008000540a <sys_close>:
{
    8000540a:	1101                	addi	sp,sp,-32
    8000540c:	ec06                	sd	ra,24(sp)
    8000540e:	e822                	sd	s0,16(sp)
    80005410:	1000                	addi	s0,sp,32
  if(argfd(0, &fd, &f) < 0)
    80005412:	fe040613          	addi	a2,s0,-32
    80005416:	fec40593          	addi	a1,s0,-20
    8000541a:	4501                	li	a0,0
    8000541c:	00000097          	auipc	ra,0x0
    80005420:	c3e080e7          	jalr	-962(ra) # 8000505a <argfd>
    return -1;
    80005424:	57fd                	li	a5,-1
  if(argfd(0, &fd, &f) < 0)
    80005426:	02054463          	bltz	a0,8000544e <sys_close+0x44>
  myproc()->ofile[fd] = 0;
    8000542a:	ffffc097          	auipc	ra,0xffffc
    8000542e:	580080e7          	jalr	1408(ra) # 800019aa <myproc>
    80005432:	fec42783          	lw	a5,-20(s0)
    80005436:	07e9                	addi	a5,a5,26
    80005438:	078e                	slli	a5,a5,0x3
    8000543a:	953e                	add	a0,a0,a5
    8000543c:	00053023          	sd	zero,0(a0)
  fileclose(f);
    80005440:	fe043503          	ld	a0,-32(s0)
    80005444:	fffff097          	auipc	ra,0xfffff
    80005448:	21a080e7          	jalr	538(ra) # 8000465e <fileclose>
  return 0;
    8000544c:	4781                	li	a5,0
}
    8000544e:	853e                	mv	a0,a5
    80005450:	60e2                	ld	ra,24(sp)
    80005452:	6442                	ld	s0,16(sp)
    80005454:	6105                	addi	sp,sp,32
    80005456:	8082                	ret

0000000080005458 <sys_fstat>:
{
    80005458:	1101                	addi	sp,sp,-32
    8000545a:	ec06                	sd	ra,24(sp)
    8000545c:	e822                	sd	s0,16(sp)
    8000545e:	1000                	addi	s0,sp,32
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005460:	fe840613          	addi	a2,s0,-24
    80005464:	4581                	li	a1,0
    80005466:	4501                	li	a0,0
    80005468:	00000097          	auipc	ra,0x0
    8000546c:	bf2080e7          	jalr	-1038(ra) # 8000505a <argfd>
    return -1;
    80005470:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005472:	02054563          	bltz	a0,8000549c <sys_fstat+0x44>
    80005476:	fe040593          	addi	a1,s0,-32
    8000547a:	4505                	li	a0,1
    8000547c:	ffffd097          	auipc	ra,0xffffd
    80005480:	610080e7          	jalr	1552(ra) # 80002a8c <argaddr>
    return -1;
    80005484:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005486:	00054b63          	bltz	a0,8000549c <sys_fstat+0x44>
  return filestat(f, st);
    8000548a:	fe043583          	ld	a1,-32(s0)
    8000548e:	fe843503          	ld	a0,-24(s0)
    80005492:	fffff097          	auipc	ra,0xfffff
    80005496:	294080e7          	jalr	660(ra) # 80004726 <filestat>
    8000549a:	87aa                	mv	a5,a0
}
    8000549c:	853e                	mv	a0,a5
    8000549e:	60e2                	ld	ra,24(sp)
    800054a0:	6442                	ld	s0,16(sp)
    800054a2:	6105                	addi	sp,sp,32
    800054a4:	8082                	ret

00000000800054a6 <sys_link>:
{
    800054a6:	7169                	addi	sp,sp,-304
    800054a8:	f606                	sd	ra,296(sp)
    800054aa:	f222                	sd	s0,288(sp)
    800054ac:	ee26                	sd	s1,280(sp)
    800054ae:	ea4a                	sd	s2,272(sp)
    800054b0:	1a00                	addi	s0,sp,304
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    800054b2:	08000613          	li	a2,128
    800054b6:	ed040593          	addi	a1,s0,-304
    800054ba:	4501                	li	a0,0
    800054bc:	ffffd097          	auipc	ra,0xffffd
    800054c0:	5f2080e7          	jalr	1522(ra) # 80002aae <argstr>
    return -1;
    800054c4:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    800054c6:	10054e63          	bltz	a0,800055e2 <sys_link+0x13c>
    800054ca:	08000613          	li	a2,128
    800054ce:	f5040593          	addi	a1,s0,-176
    800054d2:	4505                	li	a0,1
    800054d4:	ffffd097          	auipc	ra,0xffffd
    800054d8:	5da080e7          	jalr	1498(ra) # 80002aae <argstr>
    return -1;
    800054dc:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    800054de:	10054263          	bltz	a0,800055e2 <sys_link+0x13c>
  begin_op();
    800054e2:	fffff097          	auipc	ra,0xfffff
    800054e6:	cac080e7          	jalr	-852(ra) # 8000418e <begin_op>
  if((ip = namei(old)) == 0){
    800054ea:	ed040513          	addi	a0,s0,-304
    800054ee:	fffff097          	auipc	ra,0xfffff
    800054f2:	a80080e7          	jalr	-1408(ra) # 80003f6e <namei>
    800054f6:	84aa                	mv	s1,a0
    800054f8:	c551                	beqz	a0,80005584 <sys_link+0xde>
  ilock(ip);
    800054fa:	ffffe097          	auipc	ra,0xffffe
    800054fe:	1aa080e7          	jalr	426(ra) # 800036a4 <ilock>
  if(ip->type == T_DIR){
    80005502:	04449703          	lh	a4,68(s1)
    80005506:	4785                	li	a5,1
    80005508:	08f70463          	beq	a4,a5,80005590 <sys_link+0xea>
  ip->nlink++;
    8000550c:	04a4d783          	lhu	a5,74(s1)
    80005510:	2785                	addiw	a5,a5,1
    80005512:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    80005516:	8526                	mv	a0,s1
    80005518:	ffffe097          	auipc	ra,0xffffe
    8000551c:	0c0080e7          	jalr	192(ra) # 800035d8 <iupdate>
  iunlock(ip);
    80005520:	8526                	mv	a0,s1
    80005522:	ffffe097          	auipc	ra,0xffffe
    80005526:	244080e7          	jalr	580(ra) # 80003766 <iunlock>
  if((dp = nameiparent(new, name)) == 0)
    8000552a:	fd040593          	addi	a1,s0,-48
    8000552e:	f5040513          	addi	a0,s0,-176
    80005532:	fffff097          	auipc	ra,0xfffff
    80005536:	a5a080e7          	jalr	-1446(ra) # 80003f8c <nameiparent>
    8000553a:	892a                	mv	s2,a0
    8000553c:	c935                	beqz	a0,800055b0 <sys_link+0x10a>
  ilock(dp);
    8000553e:	ffffe097          	auipc	ra,0xffffe
    80005542:	166080e7          	jalr	358(ra) # 800036a4 <ilock>
  if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){
    80005546:	00092703          	lw	a4,0(s2)
    8000554a:	409c                	lw	a5,0(s1)
    8000554c:	04f71d63          	bne	a4,a5,800055a6 <sys_link+0x100>
    80005550:	40d0                	lw	a2,4(s1)
    80005552:	fd040593          	addi	a1,s0,-48
    80005556:	854a                	mv	a0,s2
    80005558:	fffff097          	auipc	ra,0xfffff
    8000555c:	954080e7          	jalr	-1708(ra) # 80003eac <dirlink>
    80005560:	04054363          	bltz	a0,800055a6 <sys_link+0x100>
  iunlockput(dp);
    80005564:	854a                	mv	a0,s2
    80005566:	ffffe097          	auipc	ra,0xffffe
    8000556a:	446080e7          	jalr	1094(ra) # 800039ac <iunlockput>
  iput(ip);
    8000556e:	8526                	mv	a0,s1
    80005570:	ffffe097          	auipc	ra,0xffffe
    80005574:	394080e7          	jalr	916(ra) # 80003904 <iput>
  end_op();
    80005578:	fffff097          	auipc	ra,0xfffff
    8000557c:	c94080e7          	jalr	-876(ra) # 8000420c <end_op>
  return 0;
    80005580:	4781                	li	a5,0
    80005582:	a085                	j	800055e2 <sys_link+0x13c>
    end_op();
    80005584:	fffff097          	auipc	ra,0xfffff
    80005588:	c88080e7          	jalr	-888(ra) # 8000420c <end_op>
    return -1;
    8000558c:	57fd                	li	a5,-1
    8000558e:	a891                	j	800055e2 <sys_link+0x13c>
    iunlockput(ip);
    80005590:	8526                	mv	a0,s1
    80005592:	ffffe097          	auipc	ra,0xffffe
    80005596:	41a080e7          	jalr	1050(ra) # 800039ac <iunlockput>
    end_op();
    8000559a:	fffff097          	auipc	ra,0xfffff
    8000559e:	c72080e7          	jalr	-910(ra) # 8000420c <end_op>
    return -1;
    800055a2:	57fd                	li	a5,-1
    800055a4:	a83d                	j	800055e2 <sys_link+0x13c>
    iunlockput(dp);
    800055a6:	854a                	mv	a0,s2
    800055a8:	ffffe097          	auipc	ra,0xffffe
    800055ac:	404080e7          	jalr	1028(ra) # 800039ac <iunlockput>
  ilock(ip);
    800055b0:	8526                	mv	a0,s1
    800055b2:	ffffe097          	auipc	ra,0xffffe
    800055b6:	0f2080e7          	jalr	242(ra) # 800036a4 <ilock>
  ip->nlink--;
    800055ba:	04a4d783          	lhu	a5,74(s1)
    800055be:	37fd                	addiw	a5,a5,-1
    800055c0:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    800055c4:	8526                	mv	a0,s1
    800055c6:	ffffe097          	auipc	ra,0xffffe
    800055ca:	012080e7          	jalr	18(ra) # 800035d8 <iupdate>
  iunlockput(ip);
    800055ce:	8526                	mv	a0,s1
    800055d0:	ffffe097          	auipc	ra,0xffffe
    800055d4:	3dc080e7          	jalr	988(ra) # 800039ac <iunlockput>
  end_op();
    800055d8:	fffff097          	auipc	ra,0xfffff
    800055dc:	c34080e7          	jalr	-972(ra) # 8000420c <end_op>
  return -1;
    800055e0:	57fd                	li	a5,-1
}
    800055e2:	853e                	mv	a0,a5
    800055e4:	70b2                	ld	ra,296(sp)
    800055e6:	7412                	ld	s0,288(sp)
    800055e8:	64f2                	ld	s1,280(sp)
    800055ea:	6952                	ld	s2,272(sp)
    800055ec:	6155                	addi	sp,sp,304
    800055ee:	8082                	ret

00000000800055f0 <sys_unlink>:
{
    800055f0:	7151                	addi	sp,sp,-240
    800055f2:	f586                	sd	ra,232(sp)
    800055f4:	f1a2                	sd	s0,224(sp)
    800055f6:	eda6                	sd	s1,216(sp)
    800055f8:	e9ca                	sd	s2,208(sp)
    800055fa:	e5ce                	sd	s3,200(sp)
    800055fc:	1980                	addi	s0,sp,240
  if(argstr(0, path, MAXPATH) < 0)
    800055fe:	08000613          	li	a2,128
    80005602:	f3040593          	addi	a1,s0,-208
    80005606:	4501                	li	a0,0
    80005608:	ffffd097          	auipc	ra,0xffffd
    8000560c:	4a6080e7          	jalr	1190(ra) # 80002aae <argstr>
    80005610:	18054163          	bltz	a0,80005792 <sys_unlink+0x1a2>
  begin_op();
    80005614:	fffff097          	auipc	ra,0xfffff
    80005618:	b7a080e7          	jalr	-1158(ra) # 8000418e <begin_op>
  if((dp = nameiparent(path, name)) == 0){
    8000561c:	fb040593          	addi	a1,s0,-80
    80005620:	f3040513          	addi	a0,s0,-208
    80005624:	fffff097          	auipc	ra,0xfffff
    80005628:	968080e7          	jalr	-1688(ra) # 80003f8c <nameiparent>
    8000562c:	84aa                	mv	s1,a0
    8000562e:	c979                	beqz	a0,80005704 <sys_unlink+0x114>
  ilock(dp);
    80005630:	ffffe097          	auipc	ra,0xffffe
    80005634:	074080e7          	jalr	116(ra) # 800036a4 <ilock>
  if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0)
    80005638:	00003597          	auipc	a1,0x3
    8000563c:	0a058593          	addi	a1,a1,160 # 800086d8 <syscalls+0x2b8>
    80005640:	fb040513          	addi	a0,s0,-80
    80005644:	ffffe097          	auipc	ra,0xffffe
    80005648:	5d2080e7          	jalr	1490(ra) # 80003c16 <namecmp>
    8000564c:	14050a63          	beqz	a0,800057a0 <sys_unlink+0x1b0>
    80005650:	00003597          	auipc	a1,0x3
    80005654:	09058593          	addi	a1,a1,144 # 800086e0 <syscalls+0x2c0>
    80005658:	fb040513          	addi	a0,s0,-80
    8000565c:	ffffe097          	auipc	ra,0xffffe
    80005660:	5ba080e7          	jalr	1466(ra) # 80003c16 <namecmp>
    80005664:	12050e63          	beqz	a0,800057a0 <sys_unlink+0x1b0>
  if((ip = dirlookup(dp, name, &off)) == 0)
    80005668:	f2c40613          	addi	a2,s0,-212
    8000566c:	fb040593          	addi	a1,s0,-80
    80005670:	8526                	mv	a0,s1
    80005672:	ffffe097          	auipc	ra,0xffffe
    80005676:	624080e7          	jalr	1572(ra) # 80003c96 <dirlookup>
    8000567a:	892a                	mv	s2,a0
    8000567c:	12050263          	beqz	a0,800057a0 <sys_unlink+0x1b0>
  ilock(ip);
    80005680:	ffffe097          	auipc	ra,0xffffe
    80005684:	024080e7          	jalr	36(ra) # 800036a4 <ilock>
  if(ip->nlink < 1)
    80005688:	04a91783          	lh	a5,74(s2)
    8000568c:	08f05263          	blez	a5,80005710 <sys_unlink+0x120>
  if(ip->type == T_DIR && !isdirempty(ip)){
    80005690:	04491703          	lh	a4,68(s2)
    80005694:	4785                	li	a5,1
    80005696:	08f70563          	beq	a4,a5,80005720 <sys_unlink+0x130>
  memset(&de, 0, sizeof(de));
    8000569a:	4641                	li	a2,16
    8000569c:	4581                	li	a1,0
    8000569e:	fc040513          	addi	a0,s0,-64
    800056a2:	ffffb097          	auipc	ra,0xffffb
    800056a6:	61c080e7          	jalr	1564(ra) # 80000cbe <memset>
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    800056aa:	4741                	li	a4,16
    800056ac:	f2c42683          	lw	a3,-212(s0)
    800056b0:	fc040613          	addi	a2,s0,-64
    800056b4:	4581                	li	a1,0
    800056b6:	8526                	mv	a0,s1
    800056b8:	ffffe097          	auipc	ra,0xffffe
    800056bc:	43e080e7          	jalr	1086(ra) # 80003af6 <writei>
    800056c0:	47c1                	li	a5,16
    800056c2:	0af51563          	bne	a0,a5,8000576c <sys_unlink+0x17c>
  if(ip->type == T_DIR){
    800056c6:	04491703          	lh	a4,68(s2)
    800056ca:	4785                	li	a5,1
    800056cc:	0af70863          	beq	a4,a5,8000577c <sys_unlink+0x18c>
  iunlockput(dp);
    800056d0:	8526                	mv	a0,s1
    800056d2:	ffffe097          	auipc	ra,0xffffe
    800056d6:	2da080e7          	jalr	730(ra) # 800039ac <iunlockput>
  ip->nlink--;
    800056da:	04a95783          	lhu	a5,74(s2)
    800056de:	37fd                	addiw	a5,a5,-1
    800056e0:	04f91523          	sh	a5,74(s2)
  iupdate(ip);
    800056e4:	854a                	mv	a0,s2
    800056e6:	ffffe097          	auipc	ra,0xffffe
    800056ea:	ef2080e7          	jalr	-270(ra) # 800035d8 <iupdate>
  iunlockput(ip);
    800056ee:	854a                	mv	a0,s2
    800056f0:	ffffe097          	auipc	ra,0xffffe
    800056f4:	2bc080e7          	jalr	700(ra) # 800039ac <iunlockput>
  end_op();
    800056f8:	fffff097          	auipc	ra,0xfffff
    800056fc:	b14080e7          	jalr	-1260(ra) # 8000420c <end_op>
  return 0;
    80005700:	4501                	li	a0,0
    80005702:	a84d                	j	800057b4 <sys_unlink+0x1c4>
    end_op();
    80005704:	fffff097          	auipc	ra,0xfffff
    80005708:	b08080e7          	jalr	-1272(ra) # 8000420c <end_op>
    return -1;
    8000570c:	557d                	li	a0,-1
    8000570e:	a05d                	j	800057b4 <sys_unlink+0x1c4>
    panic("unlink: nlink < 1");
    80005710:	00003517          	auipc	a0,0x3
    80005714:	ff850513          	addi	a0,a0,-8 # 80008708 <syscalls+0x2e8>
    80005718:	ffffb097          	auipc	ra,0xffffb
    8000571c:	e14080e7          	jalr	-492(ra) # 8000052c <panic>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    80005720:	04c92703          	lw	a4,76(s2)
    80005724:	02000793          	li	a5,32
    80005728:	f6e7f9e3          	bgeu	a5,a4,8000569a <sys_unlink+0xaa>
    8000572c:	02000993          	li	s3,32
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80005730:	4741                	li	a4,16
    80005732:	86ce                	mv	a3,s3
    80005734:	f1840613          	addi	a2,s0,-232
    80005738:	4581                	li	a1,0
    8000573a:	854a                	mv	a0,s2
    8000573c:	ffffe097          	auipc	ra,0xffffe
    80005740:	2c2080e7          	jalr	706(ra) # 800039fe <readi>
    80005744:	47c1                	li	a5,16
    80005746:	00f51b63          	bne	a0,a5,8000575c <sys_unlink+0x16c>
    if(de.inum != 0)
    8000574a:	f1845783          	lhu	a5,-232(s0)
    8000574e:	e7a1                	bnez	a5,80005796 <sys_unlink+0x1a6>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    80005750:	29c1                	addiw	s3,s3,16
    80005752:	04c92783          	lw	a5,76(s2)
    80005756:	fcf9ede3          	bltu	s3,a5,80005730 <sys_unlink+0x140>
    8000575a:	b781                	j	8000569a <sys_unlink+0xaa>
      panic("isdirempty: readi");
    8000575c:	00003517          	auipc	a0,0x3
    80005760:	fc450513          	addi	a0,a0,-60 # 80008720 <syscalls+0x300>
    80005764:	ffffb097          	auipc	ra,0xffffb
    80005768:	dc8080e7          	jalr	-568(ra) # 8000052c <panic>
    panic("unlink: writei");
    8000576c:	00003517          	auipc	a0,0x3
    80005770:	fcc50513          	addi	a0,a0,-52 # 80008738 <syscalls+0x318>
    80005774:	ffffb097          	auipc	ra,0xffffb
    80005778:	db8080e7          	jalr	-584(ra) # 8000052c <panic>
    dp->nlink--;
    8000577c:	04a4d783          	lhu	a5,74(s1)
    80005780:	37fd                	addiw	a5,a5,-1
    80005782:	04f49523          	sh	a5,74(s1)
    iupdate(dp);
    80005786:	8526                	mv	a0,s1
    80005788:	ffffe097          	auipc	ra,0xffffe
    8000578c:	e50080e7          	jalr	-432(ra) # 800035d8 <iupdate>
    80005790:	b781                	j	800056d0 <sys_unlink+0xe0>
    return -1;
    80005792:	557d                	li	a0,-1
    80005794:	a005                	j	800057b4 <sys_unlink+0x1c4>
    iunlockput(ip);
    80005796:	854a                	mv	a0,s2
    80005798:	ffffe097          	auipc	ra,0xffffe
    8000579c:	214080e7          	jalr	532(ra) # 800039ac <iunlockput>
  iunlockput(dp);
    800057a0:	8526                	mv	a0,s1
    800057a2:	ffffe097          	auipc	ra,0xffffe
    800057a6:	20a080e7          	jalr	522(ra) # 800039ac <iunlockput>
  end_op();
    800057aa:	fffff097          	auipc	ra,0xfffff
    800057ae:	a62080e7          	jalr	-1438(ra) # 8000420c <end_op>
  return -1;
    800057b2:	557d                	li	a0,-1
}
    800057b4:	70ae                	ld	ra,232(sp)
    800057b6:	740e                	ld	s0,224(sp)
    800057b8:	64ee                	ld	s1,216(sp)
    800057ba:	694e                	ld	s2,208(sp)
    800057bc:	69ae                	ld	s3,200(sp)
    800057be:	616d                	addi	sp,sp,240
    800057c0:	8082                	ret

00000000800057c2 <sys_open>:

uint64
sys_open(void)
{
    800057c2:	7131                	addi	sp,sp,-192
    800057c4:	fd06                	sd	ra,184(sp)
    800057c6:	f922                	sd	s0,176(sp)
    800057c8:	f526                	sd	s1,168(sp)
    800057ca:	f14a                	sd	s2,160(sp)
    800057cc:	ed4e                	sd	s3,152(sp)
    800057ce:	0180                	addi	s0,sp,192
  int fd, omode;
  struct file *f;
  struct inode *ip;
  int n;

  if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
    800057d0:	08000613          	li	a2,128
    800057d4:	f5040593          	addi	a1,s0,-176
    800057d8:	4501                	li	a0,0
    800057da:	ffffd097          	auipc	ra,0xffffd
    800057de:	2d4080e7          	jalr	724(ra) # 80002aae <argstr>
    return -1;
    800057e2:	54fd                	li	s1,-1
  if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
    800057e4:	0c054163          	bltz	a0,800058a6 <sys_open+0xe4>
    800057e8:	f4c40593          	addi	a1,s0,-180
    800057ec:	4505                	li	a0,1
    800057ee:	ffffd097          	auipc	ra,0xffffd
    800057f2:	27c080e7          	jalr	636(ra) # 80002a6a <argint>
    800057f6:	0a054863          	bltz	a0,800058a6 <sys_open+0xe4>

  begin_op();
    800057fa:	fffff097          	auipc	ra,0xfffff
    800057fe:	994080e7          	jalr	-1644(ra) # 8000418e <begin_op>

  if(omode & O_CREATE){
    80005802:	f4c42783          	lw	a5,-180(s0)
    80005806:	2007f793          	andi	a5,a5,512
    8000580a:	cbdd                	beqz	a5,800058c0 <sys_open+0xfe>
    ip = create(path, T_FILE, 0, 0);
    8000580c:	4681                	li	a3,0
    8000580e:	4601                	li	a2,0
    80005810:	4589                	li	a1,2
    80005812:	f5040513          	addi	a0,s0,-176
    80005816:	00000097          	auipc	ra,0x0
    8000581a:	8ee080e7          	jalr	-1810(ra) # 80005104 <create>
    8000581e:	892a                	mv	s2,a0
    if(ip == 0){
    80005820:	c959                	beqz	a0,800058b6 <sys_open+0xf4>
      end_op();
      return -1;
    }
  }

  if(ip->type == T_DEVICE && (ip->major < 0 || ip->major >= NDEV)){
    80005822:	04491703          	lh	a4,68(s2)
    80005826:	478d                	li	a5,3
    80005828:	00f71763          	bne	a4,a5,80005836 <sys_open+0x74>
    8000582c:	04695703          	lhu	a4,70(s2)
    80005830:	47a5                	li	a5,9
    80005832:	0ce7ec63          	bltu	a5,a4,8000590a <sys_open+0x148>
    iunlockput(ip);
    end_op();
    return -1;
  }

  if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
    80005836:	fffff097          	auipc	ra,0xfffff
    8000583a:	d6c080e7          	jalr	-660(ra) # 800045a2 <filealloc>
    8000583e:	89aa                	mv	s3,a0
    80005840:	10050263          	beqz	a0,80005944 <sys_open+0x182>
    80005844:	00000097          	auipc	ra,0x0
    80005848:	87e080e7          	jalr	-1922(ra) # 800050c2 <fdalloc>
    8000584c:	84aa                	mv	s1,a0
    8000584e:	0e054663          	bltz	a0,8000593a <sys_open+0x178>
    iunlockput(ip);
    end_op();
    return -1;
  }

  if(ip->type == T_DEVICE){
    80005852:	04491703          	lh	a4,68(s2)
    80005856:	478d                	li	a5,3
    80005858:	0cf70463          	beq	a4,a5,80005920 <sys_open+0x15e>
    f->type = FD_DEVICE;
    f->major = ip->major;
  } else {
    f->type = FD_INODE;
    8000585c:	4789                	li	a5,2
    8000585e:	00f9a023          	sw	a5,0(s3)
    f->off = 0;
    80005862:	0209a023          	sw	zero,32(s3)
  }
  f->ip = ip;
    80005866:	0129bc23          	sd	s2,24(s3)
  f->readable = !(omode & O_WRONLY);
    8000586a:	f4c42783          	lw	a5,-180(s0)
    8000586e:	0017c713          	xori	a4,a5,1
    80005872:	8b05                	andi	a4,a4,1
    80005874:	00e98423          	sb	a4,8(s3)
  f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
    80005878:	0037f713          	andi	a4,a5,3
    8000587c:	00e03733          	snez	a4,a4
    80005880:	00e984a3          	sb	a4,9(s3)

  if((omode & O_TRUNC) && ip->type == T_FILE){
    80005884:	4007f793          	andi	a5,a5,1024
    80005888:	c791                	beqz	a5,80005894 <sys_open+0xd2>
    8000588a:	04491703          	lh	a4,68(s2)
    8000588e:	4789                	li	a5,2
    80005890:	08f70f63          	beq	a4,a5,8000592e <sys_open+0x16c>
    itrunc(ip);
  }

  iunlock(ip);
    80005894:	854a                	mv	a0,s2
    80005896:	ffffe097          	auipc	ra,0xffffe
    8000589a:	ed0080e7          	jalr	-304(ra) # 80003766 <iunlock>
  end_op();
    8000589e:	fffff097          	auipc	ra,0xfffff
    800058a2:	96e080e7          	jalr	-1682(ra) # 8000420c <end_op>

  return fd;
}
    800058a6:	8526                	mv	a0,s1
    800058a8:	70ea                	ld	ra,184(sp)
    800058aa:	744a                	ld	s0,176(sp)
    800058ac:	74aa                	ld	s1,168(sp)
    800058ae:	790a                	ld	s2,160(sp)
    800058b0:	69ea                	ld	s3,152(sp)
    800058b2:	6129                	addi	sp,sp,192
    800058b4:	8082                	ret
      end_op();
    800058b6:	fffff097          	auipc	ra,0xfffff
    800058ba:	956080e7          	jalr	-1706(ra) # 8000420c <end_op>
      return -1;
    800058be:	b7e5                	j	800058a6 <sys_open+0xe4>
    if((ip = namei(path)) == 0){
    800058c0:	f5040513          	addi	a0,s0,-176
    800058c4:	ffffe097          	auipc	ra,0xffffe
    800058c8:	6aa080e7          	jalr	1706(ra) # 80003f6e <namei>
    800058cc:	892a                	mv	s2,a0
    800058ce:	c905                	beqz	a0,800058fe <sys_open+0x13c>
    ilock(ip);
    800058d0:	ffffe097          	auipc	ra,0xffffe
    800058d4:	dd4080e7          	jalr	-556(ra) # 800036a4 <ilock>
    if(ip->type == T_DIR && omode != O_RDONLY){
    800058d8:	04491703          	lh	a4,68(s2)
    800058dc:	4785                	li	a5,1
    800058de:	f4f712e3          	bne	a4,a5,80005822 <sys_open+0x60>
    800058e2:	f4c42783          	lw	a5,-180(s0)
    800058e6:	dba1                	beqz	a5,80005836 <sys_open+0x74>
      iunlockput(ip);
    800058e8:	854a                	mv	a0,s2
    800058ea:	ffffe097          	auipc	ra,0xffffe
    800058ee:	0c2080e7          	jalr	194(ra) # 800039ac <iunlockput>
      end_op();
    800058f2:	fffff097          	auipc	ra,0xfffff
    800058f6:	91a080e7          	jalr	-1766(ra) # 8000420c <end_op>
      return -1;
    800058fa:	54fd                	li	s1,-1
    800058fc:	b76d                	j	800058a6 <sys_open+0xe4>
      end_op();
    800058fe:	fffff097          	auipc	ra,0xfffff
    80005902:	90e080e7          	jalr	-1778(ra) # 8000420c <end_op>
      return -1;
    80005906:	54fd                	li	s1,-1
    80005908:	bf79                	j	800058a6 <sys_open+0xe4>
    iunlockput(ip);
    8000590a:	854a                	mv	a0,s2
    8000590c:	ffffe097          	auipc	ra,0xffffe
    80005910:	0a0080e7          	jalr	160(ra) # 800039ac <iunlockput>
    end_op();
    80005914:	fffff097          	auipc	ra,0xfffff
    80005918:	8f8080e7          	jalr	-1800(ra) # 8000420c <end_op>
    return -1;
    8000591c:	54fd                	li	s1,-1
    8000591e:	b761                	j	800058a6 <sys_open+0xe4>
    f->type = FD_DEVICE;
    80005920:	00f9a023          	sw	a5,0(s3)
    f->major = ip->major;
    80005924:	04691783          	lh	a5,70(s2)
    80005928:	02f99223          	sh	a5,36(s3)
    8000592c:	bf2d                	j	80005866 <sys_open+0xa4>
    itrunc(ip);
    8000592e:	854a                	mv	a0,s2
    80005930:	ffffe097          	auipc	ra,0xffffe
    80005934:	e82080e7          	jalr	-382(ra) # 800037b2 <itrunc>
    80005938:	bfb1                	j	80005894 <sys_open+0xd2>
      fileclose(f);
    8000593a:	854e                	mv	a0,s3
    8000593c:	fffff097          	auipc	ra,0xfffff
    80005940:	d22080e7          	jalr	-734(ra) # 8000465e <fileclose>
    iunlockput(ip);
    80005944:	854a                	mv	a0,s2
    80005946:	ffffe097          	auipc	ra,0xffffe
    8000594a:	066080e7          	jalr	102(ra) # 800039ac <iunlockput>
    end_op();
    8000594e:	fffff097          	auipc	ra,0xfffff
    80005952:	8be080e7          	jalr	-1858(ra) # 8000420c <end_op>
    return -1;
    80005956:	54fd                	li	s1,-1
    80005958:	b7b9                	j	800058a6 <sys_open+0xe4>

000000008000595a <sys_mkdir>:

uint64
sys_mkdir(void)
{
    8000595a:	7175                	addi	sp,sp,-144
    8000595c:	e506                	sd	ra,136(sp)
    8000595e:	e122                	sd	s0,128(sp)
    80005960:	0900                	addi	s0,sp,144
  char path[MAXPATH];
  struct inode *ip;

  begin_op();
    80005962:	fffff097          	auipc	ra,0xfffff
    80005966:	82c080e7          	jalr	-2004(ra) # 8000418e <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){
    8000596a:	08000613          	li	a2,128
    8000596e:	f7040593          	addi	a1,s0,-144
    80005972:	4501                	li	a0,0
    80005974:	ffffd097          	auipc	ra,0xffffd
    80005978:	13a080e7          	jalr	314(ra) # 80002aae <argstr>
    8000597c:	02054963          	bltz	a0,800059ae <sys_mkdir+0x54>
    80005980:	4681                	li	a3,0
    80005982:	4601                	li	a2,0
    80005984:	4585                	li	a1,1
    80005986:	f7040513          	addi	a0,s0,-144
    8000598a:	fffff097          	auipc	ra,0xfffff
    8000598e:	77a080e7          	jalr	1914(ra) # 80005104 <create>
    80005992:	cd11                	beqz	a0,800059ae <sys_mkdir+0x54>
    end_op();
    return -1;
  }
  iunlockput(ip);
    80005994:	ffffe097          	auipc	ra,0xffffe
    80005998:	018080e7          	jalr	24(ra) # 800039ac <iunlockput>
  end_op();
    8000599c:	fffff097          	auipc	ra,0xfffff
    800059a0:	870080e7          	jalr	-1936(ra) # 8000420c <end_op>
  return 0;
    800059a4:	4501                	li	a0,0
}
    800059a6:	60aa                	ld	ra,136(sp)
    800059a8:	640a                	ld	s0,128(sp)
    800059aa:	6149                	addi	sp,sp,144
    800059ac:	8082                	ret
    end_op();
    800059ae:	fffff097          	auipc	ra,0xfffff
    800059b2:	85e080e7          	jalr	-1954(ra) # 8000420c <end_op>
    return -1;
    800059b6:	557d                	li	a0,-1
    800059b8:	b7fd                	j	800059a6 <sys_mkdir+0x4c>

00000000800059ba <sys_mknod>:

uint64
sys_mknod(void)
{
    800059ba:	7135                	addi	sp,sp,-160
    800059bc:	ed06                	sd	ra,152(sp)
    800059be:	e922                	sd	s0,144(sp)
    800059c0:	1100                	addi	s0,sp,160
  struct inode *ip;
  char path[MAXPATH];
  int major, minor;

  begin_op();
    800059c2:	ffffe097          	auipc	ra,0xffffe
    800059c6:	7cc080e7          	jalr	1996(ra) # 8000418e <begin_op>
  if((argstr(0, path, MAXPATH)) < 0 ||
    800059ca:	08000613          	li	a2,128
    800059ce:	f7040593          	addi	a1,s0,-144
    800059d2:	4501                	li	a0,0
    800059d4:	ffffd097          	auipc	ra,0xffffd
    800059d8:	0da080e7          	jalr	218(ra) # 80002aae <argstr>
    800059dc:	04054a63          	bltz	a0,80005a30 <sys_mknod+0x76>
     argint(1, &major) < 0 ||
    800059e0:	f6c40593          	addi	a1,s0,-148
    800059e4:	4505                	li	a0,1
    800059e6:	ffffd097          	auipc	ra,0xffffd
    800059ea:	084080e7          	jalr	132(ra) # 80002a6a <argint>
  if((argstr(0, path, MAXPATH)) < 0 ||
    800059ee:	04054163          	bltz	a0,80005a30 <sys_mknod+0x76>
     argint(2, &minor) < 0 ||
    800059f2:	f6840593          	addi	a1,s0,-152
    800059f6:	4509                	li	a0,2
    800059f8:	ffffd097          	auipc	ra,0xffffd
    800059fc:	072080e7          	jalr	114(ra) # 80002a6a <argint>
     argint(1, &major) < 0 ||
    80005a00:	02054863          	bltz	a0,80005a30 <sys_mknod+0x76>
     (ip = create(path, T_DEVICE, major, minor)) == 0){
    80005a04:	f6841683          	lh	a3,-152(s0)
    80005a08:	f6c41603          	lh	a2,-148(s0)
    80005a0c:	458d                	li	a1,3
    80005a0e:	f7040513          	addi	a0,s0,-144
    80005a12:	fffff097          	auipc	ra,0xfffff
    80005a16:	6f2080e7          	jalr	1778(ra) # 80005104 <create>
     argint(2, &minor) < 0 ||
    80005a1a:	c919                	beqz	a0,80005a30 <sys_mknod+0x76>
    end_op();
    return -1;
  }
  iunlockput(ip);
    80005a1c:	ffffe097          	auipc	ra,0xffffe
    80005a20:	f90080e7          	jalr	-112(ra) # 800039ac <iunlockput>
  end_op();
    80005a24:	ffffe097          	auipc	ra,0xffffe
    80005a28:	7e8080e7          	jalr	2024(ra) # 8000420c <end_op>
  return 0;
    80005a2c:	4501                	li	a0,0
    80005a2e:	a031                	j	80005a3a <sys_mknod+0x80>
    end_op();
    80005a30:	ffffe097          	auipc	ra,0xffffe
    80005a34:	7dc080e7          	jalr	2012(ra) # 8000420c <end_op>
    return -1;
    80005a38:	557d                	li	a0,-1
}
    80005a3a:	60ea                	ld	ra,152(sp)
    80005a3c:	644a                	ld	s0,144(sp)
    80005a3e:	610d                	addi	sp,sp,160
    80005a40:	8082                	ret

0000000080005a42 <sys_chdir>:

uint64
sys_chdir(void)
{
    80005a42:	7135                	addi	sp,sp,-160
    80005a44:	ed06                	sd	ra,152(sp)
    80005a46:	e922                	sd	s0,144(sp)
    80005a48:	e526                	sd	s1,136(sp)
    80005a4a:	e14a                	sd	s2,128(sp)
    80005a4c:	1100                	addi	s0,sp,160
  char path[MAXPATH];
  struct inode *ip;
  struct proc *p = myproc();
    80005a4e:	ffffc097          	auipc	ra,0xffffc
    80005a52:	f5c080e7          	jalr	-164(ra) # 800019aa <myproc>
    80005a56:	892a                	mv	s2,a0
  
  begin_op();
    80005a58:	ffffe097          	auipc	ra,0xffffe
    80005a5c:	736080e7          	jalr	1846(ra) # 8000418e <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = namei(path)) == 0){
    80005a60:	08000613          	li	a2,128
    80005a64:	f6040593          	addi	a1,s0,-160
    80005a68:	4501                	li	a0,0
    80005a6a:	ffffd097          	auipc	ra,0xffffd
    80005a6e:	044080e7          	jalr	68(ra) # 80002aae <argstr>
    80005a72:	04054b63          	bltz	a0,80005ac8 <sys_chdir+0x86>
    80005a76:	f6040513          	addi	a0,s0,-160
    80005a7a:	ffffe097          	auipc	ra,0xffffe
    80005a7e:	4f4080e7          	jalr	1268(ra) # 80003f6e <namei>
    80005a82:	84aa                	mv	s1,a0
    80005a84:	c131                	beqz	a0,80005ac8 <sys_chdir+0x86>
    end_op();
    return -1;
  }
  ilock(ip);
    80005a86:	ffffe097          	auipc	ra,0xffffe
    80005a8a:	c1e080e7          	jalr	-994(ra) # 800036a4 <ilock>
  if(ip->type != T_DIR){
    80005a8e:	04449703          	lh	a4,68(s1)
    80005a92:	4785                	li	a5,1
    80005a94:	04f71063          	bne	a4,a5,80005ad4 <sys_chdir+0x92>
    iunlockput(ip);
    end_op();
    return -1;
  }
  iunlock(ip);
    80005a98:	8526                	mv	a0,s1
    80005a9a:	ffffe097          	auipc	ra,0xffffe
    80005a9e:	ccc080e7          	jalr	-820(ra) # 80003766 <iunlock>
  iput(p->cwd);
    80005aa2:	15093503          	ld	a0,336(s2)
    80005aa6:	ffffe097          	auipc	ra,0xffffe
    80005aaa:	e5e080e7          	jalr	-418(ra) # 80003904 <iput>
  end_op();
    80005aae:	ffffe097          	auipc	ra,0xffffe
    80005ab2:	75e080e7          	jalr	1886(ra) # 8000420c <end_op>
  p->cwd = ip;
    80005ab6:	14993823          	sd	s1,336(s2)
  return 0;
    80005aba:	4501                	li	a0,0
}
    80005abc:	60ea                	ld	ra,152(sp)
    80005abe:	644a                	ld	s0,144(sp)
    80005ac0:	64aa                	ld	s1,136(sp)
    80005ac2:	690a                	ld	s2,128(sp)
    80005ac4:	610d                	addi	sp,sp,160
    80005ac6:	8082                	ret
    end_op();
    80005ac8:	ffffe097          	auipc	ra,0xffffe
    80005acc:	744080e7          	jalr	1860(ra) # 8000420c <end_op>
    return -1;
    80005ad0:	557d                	li	a0,-1
    80005ad2:	b7ed                	j	80005abc <sys_chdir+0x7a>
    iunlockput(ip);
    80005ad4:	8526                	mv	a0,s1
    80005ad6:	ffffe097          	auipc	ra,0xffffe
    80005ada:	ed6080e7          	jalr	-298(ra) # 800039ac <iunlockput>
    end_op();
    80005ade:	ffffe097          	auipc	ra,0xffffe
    80005ae2:	72e080e7          	jalr	1838(ra) # 8000420c <end_op>
    return -1;
    80005ae6:	557d                	li	a0,-1
    80005ae8:	bfd1                	j	80005abc <sys_chdir+0x7a>

0000000080005aea <sys_exec>:

uint64
sys_exec(void)
{
    80005aea:	7145                	addi	sp,sp,-464
    80005aec:	e786                	sd	ra,456(sp)
    80005aee:	e3a2                	sd	s0,448(sp)
    80005af0:	ff26                	sd	s1,440(sp)
    80005af2:	fb4a                	sd	s2,432(sp)
    80005af4:	f74e                	sd	s3,424(sp)
    80005af6:	f352                	sd	s4,416(sp)
    80005af8:	ef56                	sd	s5,408(sp)
    80005afa:	0b80                	addi	s0,sp,464
  char path[MAXPATH], *argv[MAXARG];
  int i;
  uint64 uargv, uarg;

  if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
    80005afc:	08000613          	li	a2,128
    80005b00:	f4040593          	addi	a1,s0,-192
    80005b04:	4501                	li	a0,0
    80005b06:	ffffd097          	auipc	ra,0xffffd
    80005b0a:	fa8080e7          	jalr	-88(ra) # 80002aae <argstr>
    return -1;
    80005b0e:	597d                	li	s2,-1
  if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
    80005b10:	0c054b63          	bltz	a0,80005be6 <sys_exec+0xfc>
    80005b14:	e3840593          	addi	a1,s0,-456
    80005b18:	4505                	li	a0,1
    80005b1a:	ffffd097          	auipc	ra,0xffffd
    80005b1e:	f72080e7          	jalr	-142(ra) # 80002a8c <argaddr>
    80005b22:	0c054263          	bltz	a0,80005be6 <sys_exec+0xfc>
  }
  memset(argv, 0, sizeof(argv));
    80005b26:	10000613          	li	a2,256
    80005b2a:	4581                	li	a1,0
    80005b2c:	e4040513          	addi	a0,s0,-448
    80005b30:	ffffb097          	auipc	ra,0xffffb
    80005b34:	18e080e7          	jalr	398(ra) # 80000cbe <memset>
  for(i=0;; i++){
    if(i >= NELEM(argv)){
    80005b38:	e4040493          	addi	s1,s0,-448
  memset(argv, 0, sizeof(argv));
    80005b3c:	89a6                	mv	s3,s1
    80005b3e:	4901                	li	s2,0
    if(i >= NELEM(argv)){
    80005b40:	02000a13          	li	s4,32
    80005b44:	00090a9b          	sext.w	s5,s2
      goto bad;
    }
    if(fetchaddr(uargv+sizeof(uint64)*i, (uint64*)&uarg) < 0){
    80005b48:	00391513          	slli	a0,s2,0x3
    80005b4c:	e3040593          	addi	a1,s0,-464
    80005b50:	e3843783          	ld	a5,-456(s0)
    80005b54:	953e                	add	a0,a0,a5
    80005b56:	ffffd097          	auipc	ra,0xffffd
    80005b5a:	e7a080e7          	jalr	-390(ra) # 800029d0 <fetchaddr>
    80005b5e:	02054a63          	bltz	a0,80005b92 <sys_exec+0xa8>
      goto bad;
    }
    if(uarg == 0){
    80005b62:	e3043783          	ld	a5,-464(s0)
    80005b66:	c3b9                	beqz	a5,80005bac <sys_exec+0xc2>
      argv[i] = 0;
      break;
    }
    argv[i] = kalloc();
    80005b68:	ffffb097          	auipc	ra,0xffffb
    80005b6c:	f6a080e7          	jalr	-150(ra) # 80000ad2 <kalloc>
    80005b70:	85aa                	mv	a1,a0
    80005b72:	00a9b023          	sd	a0,0(s3)
    if(argv[i] == 0)
    80005b76:	cd11                	beqz	a0,80005b92 <sys_exec+0xa8>
      goto bad;
    if(fetchstr(uarg, argv[i], PGSIZE) < 0)
    80005b78:	6605                	lui	a2,0x1
    80005b7a:	e3043503          	ld	a0,-464(s0)
    80005b7e:	ffffd097          	auipc	ra,0xffffd
    80005b82:	ea4080e7          	jalr	-348(ra) # 80002a22 <fetchstr>
    80005b86:	00054663          	bltz	a0,80005b92 <sys_exec+0xa8>
    if(i >= NELEM(argv)){
    80005b8a:	0905                	addi	s2,s2,1
    80005b8c:	09a1                	addi	s3,s3,8
    80005b8e:	fb491be3          	bne	s2,s4,80005b44 <sys_exec+0x5a>
    kfree(argv[i]);

  return ret;

 bad:
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005b92:	f4040913          	addi	s2,s0,-192
    80005b96:	6088                	ld	a0,0(s1)
    80005b98:	c531                	beqz	a0,80005be4 <sys_exec+0xfa>
    kfree(argv[i]);
    80005b9a:	ffffb097          	auipc	ra,0xffffb
    80005b9e:	e3a080e7          	jalr	-454(ra) # 800009d4 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005ba2:	04a1                	addi	s1,s1,8
    80005ba4:	ff2499e3          	bne	s1,s2,80005b96 <sys_exec+0xac>
  return -1;
    80005ba8:	597d                	li	s2,-1
    80005baa:	a835                	j	80005be6 <sys_exec+0xfc>
      argv[i] = 0;
    80005bac:	0a8e                	slli	s5,s5,0x3
    80005bae:	fc0a8793          	addi	a5,s5,-64 # ffffffffffffefc0 <end+0xffffffff7ffddfc0>
    80005bb2:	00878ab3          	add	s5,a5,s0
    80005bb6:	e80ab023          	sd	zero,-384(s5)
  int ret = exec(path, argv);
    80005bba:	e4040593          	addi	a1,s0,-448
    80005bbe:	f4040513          	addi	a0,s0,-192
    80005bc2:	fffff097          	auipc	ra,0xfffff
    80005bc6:	0f0080e7          	jalr	240(ra) # 80004cb2 <exec>
    80005bca:	892a                	mv	s2,a0
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005bcc:	f4040993          	addi	s3,s0,-192
    80005bd0:	6088                	ld	a0,0(s1)
    80005bd2:	c911                	beqz	a0,80005be6 <sys_exec+0xfc>
    kfree(argv[i]);
    80005bd4:	ffffb097          	auipc	ra,0xffffb
    80005bd8:	e00080e7          	jalr	-512(ra) # 800009d4 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005bdc:	04a1                	addi	s1,s1,8
    80005bde:	ff3499e3          	bne	s1,s3,80005bd0 <sys_exec+0xe6>
    80005be2:	a011                	j	80005be6 <sys_exec+0xfc>
  return -1;
    80005be4:	597d                	li	s2,-1
}
    80005be6:	854a                	mv	a0,s2
    80005be8:	60be                	ld	ra,456(sp)
    80005bea:	641e                	ld	s0,448(sp)
    80005bec:	74fa                	ld	s1,440(sp)
    80005bee:	795a                	ld	s2,432(sp)
    80005bf0:	79ba                	ld	s3,424(sp)
    80005bf2:	7a1a                	ld	s4,416(sp)
    80005bf4:	6afa                	ld	s5,408(sp)
    80005bf6:	6179                	addi	sp,sp,464
    80005bf8:	8082                	ret

0000000080005bfa <sys_pipe>:

uint64
sys_pipe(void)
{
    80005bfa:	7139                	addi	sp,sp,-64
    80005bfc:	fc06                	sd	ra,56(sp)
    80005bfe:	f822                	sd	s0,48(sp)
    80005c00:	f426                	sd	s1,40(sp)
    80005c02:	0080                	addi	s0,sp,64
  uint64 fdarray; // user pointer to array of two integers
  struct file *rf, *wf;
  int fd0, fd1;
  struct proc *p = myproc();
    80005c04:	ffffc097          	auipc	ra,0xffffc
    80005c08:	da6080e7          	jalr	-602(ra) # 800019aa <myproc>
    80005c0c:	84aa                	mv	s1,a0

  if(argaddr(0, &fdarray) < 0)
    80005c0e:	fd840593          	addi	a1,s0,-40
    80005c12:	4501                	li	a0,0
    80005c14:	ffffd097          	auipc	ra,0xffffd
    80005c18:	e78080e7          	jalr	-392(ra) # 80002a8c <argaddr>
    return -1;
    80005c1c:	57fd                	li	a5,-1
  if(argaddr(0, &fdarray) < 0)
    80005c1e:	0e054063          	bltz	a0,80005cfe <sys_pipe+0x104>
  if(pipealloc(&rf, &wf) < 0)
    80005c22:	fc840593          	addi	a1,s0,-56
    80005c26:	fd040513          	addi	a0,s0,-48
    80005c2a:	fffff097          	auipc	ra,0xfffff
    80005c2e:	d64080e7          	jalr	-668(ra) # 8000498e <pipealloc>
    return -1;
    80005c32:	57fd                	li	a5,-1
  if(pipealloc(&rf, &wf) < 0)
    80005c34:	0c054563          	bltz	a0,80005cfe <sys_pipe+0x104>
  fd0 = -1;
    80005c38:	fcf42223          	sw	a5,-60(s0)
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
    80005c3c:	fd043503          	ld	a0,-48(s0)
    80005c40:	fffff097          	auipc	ra,0xfffff
    80005c44:	482080e7          	jalr	1154(ra) # 800050c2 <fdalloc>
    80005c48:	fca42223          	sw	a0,-60(s0)
    80005c4c:	08054c63          	bltz	a0,80005ce4 <sys_pipe+0xea>
    80005c50:	fc843503          	ld	a0,-56(s0)
    80005c54:	fffff097          	auipc	ra,0xfffff
    80005c58:	46e080e7          	jalr	1134(ra) # 800050c2 <fdalloc>
    80005c5c:	fca42023          	sw	a0,-64(s0)
    80005c60:	06054963          	bltz	a0,80005cd2 <sys_pipe+0xd8>
      p->ofile[fd0] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    80005c64:	4691                	li	a3,4
    80005c66:	fc440613          	addi	a2,s0,-60
    80005c6a:	fd843583          	ld	a1,-40(s0)
    80005c6e:	68a8                	ld	a0,80(s1)
    80005c70:	ffffc097          	auipc	ra,0xffffc
    80005c74:	9d2080e7          	jalr	-1582(ra) # 80001642 <copyout>
    80005c78:	02054063          	bltz	a0,80005c98 <sys_pipe+0x9e>
     copyout(p->pagetable, fdarray+sizeof(fd0), (char *)&fd1, sizeof(fd1)) < 0){
    80005c7c:	4691                	li	a3,4
    80005c7e:	fc040613          	addi	a2,s0,-64
    80005c82:	fd843583          	ld	a1,-40(s0)
    80005c86:	0591                	addi	a1,a1,4
    80005c88:	68a8                	ld	a0,80(s1)
    80005c8a:	ffffc097          	auipc	ra,0xffffc
    80005c8e:	9b8080e7          	jalr	-1608(ra) # 80001642 <copyout>
    p->ofile[fd1] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  return 0;
    80005c92:	4781                	li	a5,0
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    80005c94:	06055563          	bgez	a0,80005cfe <sys_pipe+0x104>
    p->ofile[fd0] = 0;
    80005c98:	fc442783          	lw	a5,-60(s0)
    80005c9c:	07e9                	addi	a5,a5,26
    80005c9e:	078e                	slli	a5,a5,0x3
    80005ca0:	97a6                	add	a5,a5,s1
    80005ca2:	0007b023          	sd	zero,0(a5)
    p->ofile[fd1] = 0;
    80005ca6:	fc042783          	lw	a5,-64(s0)
    80005caa:	07e9                	addi	a5,a5,26
    80005cac:	078e                	slli	a5,a5,0x3
    80005cae:	00f48533          	add	a0,s1,a5
    80005cb2:	00053023          	sd	zero,0(a0)
    fileclose(rf);
    80005cb6:	fd043503          	ld	a0,-48(s0)
    80005cba:	fffff097          	auipc	ra,0xfffff
    80005cbe:	9a4080e7          	jalr	-1628(ra) # 8000465e <fileclose>
    fileclose(wf);
    80005cc2:	fc843503          	ld	a0,-56(s0)
    80005cc6:	fffff097          	auipc	ra,0xfffff
    80005cca:	998080e7          	jalr	-1640(ra) # 8000465e <fileclose>
    return -1;
    80005cce:	57fd                	li	a5,-1
    80005cd0:	a03d                	j	80005cfe <sys_pipe+0x104>
    if(fd0 >= 0)
    80005cd2:	fc442783          	lw	a5,-60(s0)
    80005cd6:	0007c763          	bltz	a5,80005ce4 <sys_pipe+0xea>
      p->ofile[fd0] = 0;
    80005cda:	07e9                	addi	a5,a5,26
    80005cdc:	078e                	slli	a5,a5,0x3
    80005cde:	97a6                	add	a5,a5,s1
    80005ce0:	0007b023          	sd	zero,0(a5)
    fileclose(rf);
    80005ce4:	fd043503          	ld	a0,-48(s0)
    80005ce8:	fffff097          	auipc	ra,0xfffff
    80005cec:	976080e7          	jalr	-1674(ra) # 8000465e <fileclose>
    fileclose(wf);
    80005cf0:	fc843503          	ld	a0,-56(s0)
    80005cf4:	fffff097          	auipc	ra,0xfffff
    80005cf8:	96a080e7          	jalr	-1686(ra) # 8000465e <fileclose>
    return -1;
    80005cfc:	57fd                	li	a5,-1
}
    80005cfe:	853e                	mv	a0,a5
    80005d00:	70e2                	ld	ra,56(sp)
    80005d02:	7442                	ld	s0,48(sp)
    80005d04:	74a2                	ld	s1,40(sp)
    80005d06:	6121                	addi	sp,sp,64
    80005d08:	8082                	ret
    80005d0a:	0000                	unimp
    80005d0c:	0000                	unimp
	...

0000000080005d10 <kernelvec>:
    80005d10:	7111                	addi	sp,sp,-256
    80005d12:	e006                	sd	ra,0(sp)
    80005d14:	e40a                	sd	sp,8(sp)
    80005d16:	e80e                	sd	gp,16(sp)
    80005d18:	ec12                	sd	tp,24(sp)
    80005d1a:	f016                	sd	t0,32(sp)
    80005d1c:	f41a                	sd	t1,40(sp)
    80005d1e:	f81e                	sd	t2,48(sp)
    80005d20:	fc22                	sd	s0,56(sp)
    80005d22:	e0a6                	sd	s1,64(sp)
    80005d24:	e4aa                	sd	a0,72(sp)
    80005d26:	e8ae                	sd	a1,80(sp)
    80005d28:	ecb2                	sd	a2,88(sp)
    80005d2a:	f0b6                	sd	a3,96(sp)
    80005d2c:	f4ba                	sd	a4,104(sp)
    80005d2e:	f8be                	sd	a5,112(sp)
    80005d30:	fcc2                	sd	a6,120(sp)
    80005d32:	e146                	sd	a7,128(sp)
    80005d34:	e54a                	sd	s2,136(sp)
    80005d36:	e94e                	sd	s3,144(sp)
    80005d38:	ed52                	sd	s4,152(sp)
    80005d3a:	f156                	sd	s5,160(sp)
    80005d3c:	f55a                	sd	s6,168(sp)
    80005d3e:	f95e                	sd	s7,176(sp)
    80005d40:	fd62                	sd	s8,184(sp)
    80005d42:	e1e6                	sd	s9,192(sp)
    80005d44:	e5ea                	sd	s10,200(sp)
    80005d46:	e9ee                	sd	s11,208(sp)
    80005d48:	edf2                	sd	t3,216(sp)
    80005d4a:	f1f6                	sd	t4,224(sp)
    80005d4c:	f5fa                	sd	t5,232(sp)
    80005d4e:	f9fe                	sd	t6,240(sp)
    80005d50:	b4dfc0ef          	jal	ra,8000289c <kerneltrap>
    80005d54:	6082                	ld	ra,0(sp)
    80005d56:	6122                	ld	sp,8(sp)
    80005d58:	61c2                	ld	gp,16(sp)
    80005d5a:	7282                	ld	t0,32(sp)
    80005d5c:	7322                	ld	t1,40(sp)
    80005d5e:	73c2                	ld	t2,48(sp)
    80005d60:	7462                	ld	s0,56(sp)
    80005d62:	6486                	ld	s1,64(sp)
    80005d64:	6526                	ld	a0,72(sp)
    80005d66:	65c6                	ld	a1,80(sp)
    80005d68:	6666                	ld	a2,88(sp)
    80005d6a:	7686                	ld	a3,96(sp)
    80005d6c:	7726                	ld	a4,104(sp)
    80005d6e:	77c6                	ld	a5,112(sp)
    80005d70:	7866                	ld	a6,120(sp)
    80005d72:	688a                	ld	a7,128(sp)
    80005d74:	692a                	ld	s2,136(sp)
    80005d76:	69ca                	ld	s3,144(sp)
    80005d78:	6a6a                	ld	s4,152(sp)
    80005d7a:	7a8a                	ld	s5,160(sp)
    80005d7c:	7b2a                	ld	s6,168(sp)
    80005d7e:	7bca                	ld	s7,176(sp)
    80005d80:	7c6a                	ld	s8,184(sp)
    80005d82:	6c8e                	ld	s9,192(sp)
    80005d84:	6d2e                	ld	s10,200(sp)
    80005d86:	6dce                	ld	s11,208(sp)
    80005d88:	6e6e                	ld	t3,216(sp)
    80005d8a:	7e8e                	ld	t4,224(sp)
    80005d8c:	7f2e                	ld	t5,232(sp)
    80005d8e:	7fce                	ld	t6,240(sp)
    80005d90:	6111                	addi	sp,sp,256
    80005d92:	10200073          	sret
    80005d96:	00000013          	nop
    80005d9a:	00000013          	nop
    80005d9e:	0001                	nop

0000000080005da0 <timervec>:
    80005da0:	34051573          	csrrw	a0,mscratch,a0
    80005da4:	e10c                	sd	a1,0(a0)
    80005da6:	e510                	sd	a2,8(a0)
    80005da8:	e914                	sd	a3,16(a0)
    80005daa:	6d0c                	ld	a1,24(a0)
    80005dac:	7110                	ld	a2,32(a0)
    80005dae:	6194                	ld	a3,0(a1)
    80005db0:	96b2                	add	a3,a3,a2
    80005db2:	e194                	sd	a3,0(a1)
    80005db4:	4589                	li	a1,2
    80005db6:	14459073          	csrw	sip,a1
    80005dba:	6914                	ld	a3,16(a0)
    80005dbc:	6510                	ld	a2,8(a0)
    80005dbe:	610c                	ld	a1,0(a0)
    80005dc0:	34051573          	csrrw	a0,mscratch,a0
    80005dc4:	30200073          	mret
	...

0000000080005dca <plicinit>:
// the riscv Platform Level Interrupt Controller (PLIC).
//

void
plicinit(void)
{
    80005dca:	1141                	addi	sp,sp,-16
    80005dcc:	e422                	sd	s0,8(sp)
    80005dce:	0800                	addi	s0,sp,16
  // set desired IRQ priorities non-zero (otherwise disabled).
  *(uint32*)(PLIC + UART0_IRQ*4) = 1;
    80005dd0:	0c0007b7          	lui	a5,0xc000
    80005dd4:	4705                	li	a4,1
    80005dd6:	d798                	sw	a4,40(a5)
  *(uint32*)(PLIC + VIRTIO0_IRQ*4) = 1;
    80005dd8:	c3d8                	sw	a4,4(a5)
}
    80005dda:	6422                	ld	s0,8(sp)
    80005ddc:	0141                	addi	sp,sp,16
    80005dde:	8082                	ret

0000000080005de0 <plicinithart>:

void
plicinithart(void)
{
    80005de0:	1141                	addi	sp,sp,-16
    80005de2:	e406                	sd	ra,8(sp)
    80005de4:	e022                	sd	s0,0(sp)
    80005de6:	0800                	addi	s0,sp,16
  int hart = cpuid();
    80005de8:	ffffc097          	auipc	ra,0xffffc
    80005dec:	b96080e7          	jalr	-1130(ra) # 8000197e <cpuid>
  
  // set uart's enable bit for this hart's S-mode. 
  *(uint32*)PLIC_SENABLE(hart)= (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ);
    80005df0:	0085171b          	slliw	a4,a0,0x8
    80005df4:	0c0027b7          	lui	a5,0xc002
    80005df8:	97ba                	add	a5,a5,a4
    80005dfa:	40200713          	li	a4,1026
    80005dfe:	08e7a023          	sw	a4,128(a5) # c002080 <_entry-0x73ffdf80>

  // set this hart's S-mode priority threshold to 0.
  *(uint32*)PLIC_SPRIORITY(hart) = 0;
    80005e02:	00d5151b          	slliw	a0,a0,0xd
    80005e06:	0c2017b7          	lui	a5,0xc201
    80005e0a:	97aa                	add	a5,a5,a0
    80005e0c:	0007a023          	sw	zero,0(a5) # c201000 <_entry-0x73dff000>
}
    80005e10:	60a2                	ld	ra,8(sp)
    80005e12:	6402                	ld	s0,0(sp)
    80005e14:	0141                	addi	sp,sp,16
    80005e16:	8082                	ret

0000000080005e18 <plic_claim>:

// ask the PLIC what interrupt we should serve.
int
plic_claim(void)
{
    80005e18:	1141                	addi	sp,sp,-16
    80005e1a:	e406                	sd	ra,8(sp)
    80005e1c:	e022                	sd	s0,0(sp)
    80005e1e:	0800                	addi	s0,sp,16
  int hart = cpuid();
    80005e20:	ffffc097          	auipc	ra,0xffffc
    80005e24:	b5e080e7          	jalr	-1186(ra) # 8000197e <cpuid>
  int irq = *(uint32*)PLIC_SCLAIM(hart);
    80005e28:	00d5151b          	slliw	a0,a0,0xd
    80005e2c:	0c2017b7          	lui	a5,0xc201
    80005e30:	97aa                	add	a5,a5,a0
  return irq;
}
    80005e32:	43c8                	lw	a0,4(a5)
    80005e34:	60a2                	ld	ra,8(sp)
    80005e36:	6402                	ld	s0,0(sp)
    80005e38:	0141                	addi	sp,sp,16
    80005e3a:	8082                	ret

0000000080005e3c <plic_complete>:

// tell the PLIC we've served this IRQ.
void
plic_complete(int irq)
{
    80005e3c:	1101                	addi	sp,sp,-32
    80005e3e:	ec06                	sd	ra,24(sp)
    80005e40:	e822                	sd	s0,16(sp)
    80005e42:	e426                	sd	s1,8(sp)
    80005e44:	1000                	addi	s0,sp,32
    80005e46:	84aa                	mv	s1,a0
  int hart = cpuid();
    80005e48:	ffffc097          	auipc	ra,0xffffc
    80005e4c:	b36080e7          	jalr	-1226(ra) # 8000197e <cpuid>
  *(uint32*)PLIC_SCLAIM(hart) = irq;
    80005e50:	00d5151b          	slliw	a0,a0,0xd
    80005e54:	0c2017b7          	lui	a5,0xc201
    80005e58:	97aa                	add	a5,a5,a0
    80005e5a:	c3c4                	sw	s1,4(a5)
}
    80005e5c:	60e2                	ld	ra,24(sp)
    80005e5e:	6442                	ld	s0,16(sp)
    80005e60:	64a2                	ld	s1,8(sp)
    80005e62:	6105                	addi	sp,sp,32
    80005e64:	8082                	ret

0000000080005e66 <free_desc>:
}

// mark a descriptor as free.
static void
free_desc(int i)
{
    80005e66:	1141                	addi	sp,sp,-16
    80005e68:	e406                	sd	ra,8(sp)
    80005e6a:	e022                	sd	s0,0(sp)
    80005e6c:	0800                	addi	s0,sp,16
  if(i >= NUM)
    80005e6e:	479d                	li	a5,7
    80005e70:	06a7c863          	blt	a5,a0,80005ee0 <free_desc+0x7a>
    panic("free_desc 1");
  if(disk.free[i])
    80005e74:	00018717          	auipc	a4,0x18
    80005e78:	18c70713          	addi	a4,a4,396 # 8001e000 <disk>
    80005e7c:	972a                	add	a4,a4,a0
    80005e7e:	6789                	lui	a5,0x2
    80005e80:	97ba                	add	a5,a5,a4
    80005e82:	0187c783          	lbu	a5,24(a5) # 2018 <_entry-0x7fffdfe8>
    80005e86:	e7ad                	bnez	a5,80005ef0 <free_desc+0x8a>
    panic("free_desc 2");
  disk.desc[i].addr = 0;
    80005e88:	00451793          	slli	a5,a0,0x4
    80005e8c:	0001a717          	auipc	a4,0x1a
    80005e90:	17470713          	addi	a4,a4,372 # 80020000 <disk+0x2000>
    80005e94:	6314                	ld	a3,0(a4)
    80005e96:	96be                	add	a3,a3,a5
    80005e98:	0006b023          	sd	zero,0(a3)
  disk.desc[i].len = 0;
    80005e9c:	6314                	ld	a3,0(a4)
    80005e9e:	96be                	add	a3,a3,a5
    80005ea0:	0006a423          	sw	zero,8(a3)
  disk.desc[i].flags = 0;
    80005ea4:	6314                	ld	a3,0(a4)
    80005ea6:	96be                	add	a3,a3,a5
    80005ea8:	00069623          	sh	zero,12(a3)
  disk.desc[i].next = 0;
    80005eac:	6318                	ld	a4,0(a4)
    80005eae:	97ba                	add	a5,a5,a4
    80005eb0:	00079723          	sh	zero,14(a5)
  disk.free[i] = 1;
    80005eb4:	00018717          	auipc	a4,0x18
    80005eb8:	14c70713          	addi	a4,a4,332 # 8001e000 <disk>
    80005ebc:	972a                	add	a4,a4,a0
    80005ebe:	6789                	lui	a5,0x2
    80005ec0:	97ba                	add	a5,a5,a4
    80005ec2:	4705                	li	a4,1
    80005ec4:	00e78c23          	sb	a4,24(a5) # 2018 <_entry-0x7fffdfe8>
  wakeup(&disk.free[0]);
    80005ec8:	0001a517          	auipc	a0,0x1a
    80005ecc:	15050513          	addi	a0,a0,336 # 80020018 <disk+0x2018>
    80005ed0:	ffffc097          	auipc	ra,0xffffc
    80005ed4:	472080e7          	jalr	1138(ra) # 80002342 <wakeup>
}
    80005ed8:	60a2                	ld	ra,8(sp)
    80005eda:	6402                	ld	s0,0(sp)
    80005edc:	0141                	addi	sp,sp,16
    80005ede:	8082                	ret
    panic("free_desc 1");
    80005ee0:	00003517          	auipc	a0,0x3
    80005ee4:	86850513          	addi	a0,a0,-1944 # 80008748 <syscalls+0x328>
    80005ee8:	ffffa097          	auipc	ra,0xffffa
    80005eec:	644080e7          	jalr	1604(ra) # 8000052c <panic>
    panic("free_desc 2");
    80005ef0:	00003517          	auipc	a0,0x3
    80005ef4:	86850513          	addi	a0,a0,-1944 # 80008758 <syscalls+0x338>
    80005ef8:	ffffa097          	auipc	ra,0xffffa
    80005efc:	634080e7          	jalr	1588(ra) # 8000052c <panic>

0000000080005f00 <virtio_disk_init>:
{
    80005f00:	1101                	addi	sp,sp,-32
    80005f02:	ec06                	sd	ra,24(sp)
    80005f04:	e822                	sd	s0,16(sp)
    80005f06:	e426                	sd	s1,8(sp)
    80005f08:	1000                	addi	s0,sp,32
  initlock(&disk.vdisk_lock, "virtio_disk");
    80005f0a:	00003597          	auipc	a1,0x3
    80005f0e:	85e58593          	addi	a1,a1,-1954 # 80008768 <syscalls+0x348>
    80005f12:	0001a517          	auipc	a0,0x1a
    80005f16:	21650513          	addi	a0,a0,534 # 80020128 <disk+0x2128>
    80005f1a:	ffffb097          	auipc	ra,0xffffb
    80005f1e:	c18080e7          	jalr	-1000(ra) # 80000b32 <initlock>
  if(*R(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    80005f22:	100017b7          	lui	a5,0x10001
    80005f26:	4398                	lw	a4,0(a5)
    80005f28:	2701                	sext.w	a4,a4
    80005f2a:	747277b7          	lui	a5,0x74727
    80005f2e:	97678793          	addi	a5,a5,-1674 # 74726976 <_entry-0xb8d968a>
    80005f32:	0ef71063          	bne	a4,a5,80006012 <virtio_disk_init+0x112>
     *R(VIRTIO_MMIO_VERSION) != 1 ||
    80005f36:	100017b7          	lui	a5,0x10001
    80005f3a:	43dc                	lw	a5,4(a5)
    80005f3c:	2781                	sext.w	a5,a5
  if(*R(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    80005f3e:	4705                	li	a4,1
    80005f40:	0ce79963          	bne	a5,a4,80006012 <virtio_disk_init+0x112>
     *R(VIRTIO_MMIO_DEVICE_ID) != 2 ||
    80005f44:	100017b7          	lui	a5,0x10001
    80005f48:	479c                	lw	a5,8(a5)
    80005f4a:	2781                	sext.w	a5,a5
     *R(VIRTIO_MMIO_VERSION) != 1 ||
    80005f4c:	4709                	li	a4,2
    80005f4e:	0ce79263          	bne	a5,a4,80006012 <virtio_disk_init+0x112>
     *R(VIRTIO_MMIO_VENDOR_ID) != 0x554d4551){
    80005f52:	100017b7          	lui	a5,0x10001
    80005f56:	47d8                	lw	a4,12(a5)
    80005f58:	2701                	sext.w	a4,a4
     *R(VIRTIO_MMIO_DEVICE_ID) != 2 ||
    80005f5a:	554d47b7          	lui	a5,0x554d4
    80005f5e:	55178793          	addi	a5,a5,1361 # 554d4551 <_entry-0x2ab2baaf>
    80005f62:	0af71863          	bne	a4,a5,80006012 <virtio_disk_init+0x112>
  *R(VIRTIO_MMIO_STATUS) = status;
    80005f66:	100017b7          	lui	a5,0x10001
    80005f6a:	4705                	li	a4,1
    80005f6c:	dbb8                	sw	a4,112(a5)
  *R(VIRTIO_MMIO_STATUS) = status;
    80005f6e:	470d                	li	a4,3
    80005f70:	dbb8                	sw	a4,112(a5)
  uint64 features = *R(VIRTIO_MMIO_DEVICE_FEATURES);
    80005f72:	4b98                	lw	a4,16(a5)
  *R(VIRTIO_MMIO_DRIVER_FEATURES) = features;
    80005f74:	c7ffe6b7          	lui	a3,0xc7ffe
    80005f78:	75f68693          	addi	a3,a3,1887 # ffffffffc7ffe75f <end+0xffffffff47fdd75f>
    80005f7c:	8f75                	and	a4,a4,a3
    80005f7e:	d398                	sw	a4,32(a5)
  *R(VIRTIO_MMIO_STATUS) = status;
    80005f80:	472d                	li	a4,11
    80005f82:	dbb8                	sw	a4,112(a5)
  *R(VIRTIO_MMIO_STATUS) = status;
    80005f84:	473d                	li	a4,15
    80005f86:	dbb8                	sw	a4,112(a5)
  *R(VIRTIO_MMIO_GUEST_PAGE_SIZE) = PGSIZE;
    80005f88:	6705                	lui	a4,0x1
    80005f8a:	d798                	sw	a4,40(a5)
  *R(VIRTIO_MMIO_QUEUE_SEL) = 0;
    80005f8c:	0207a823          	sw	zero,48(a5) # 10001030 <_entry-0x6fffefd0>
  uint32 max = *R(VIRTIO_MMIO_QUEUE_NUM_MAX);
    80005f90:	5bdc                	lw	a5,52(a5)
    80005f92:	2781                	sext.w	a5,a5
  if(max == 0)
    80005f94:	c7d9                	beqz	a5,80006022 <virtio_disk_init+0x122>
  if(max < NUM)
    80005f96:	471d                	li	a4,7
    80005f98:	08f77d63          	bgeu	a4,a5,80006032 <virtio_disk_init+0x132>
  *R(VIRTIO_MMIO_QUEUE_NUM) = NUM;
    80005f9c:	100014b7          	lui	s1,0x10001
    80005fa0:	47a1                	li	a5,8
    80005fa2:	dc9c                	sw	a5,56(s1)
  memset(disk.pages, 0, sizeof(disk.pages));
    80005fa4:	6609                	lui	a2,0x2
    80005fa6:	4581                	li	a1,0
    80005fa8:	00018517          	auipc	a0,0x18
    80005fac:	05850513          	addi	a0,a0,88 # 8001e000 <disk>
    80005fb0:	ffffb097          	auipc	ra,0xffffb
    80005fb4:	d0e080e7          	jalr	-754(ra) # 80000cbe <memset>
  *R(VIRTIO_MMIO_QUEUE_PFN) = ((uint64)disk.pages) >> PGSHIFT;
    80005fb8:	00018717          	auipc	a4,0x18
    80005fbc:	04870713          	addi	a4,a4,72 # 8001e000 <disk>
    80005fc0:	00c75793          	srli	a5,a4,0xc
    80005fc4:	2781                	sext.w	a5,a5
    80005fc6:	c0bc                	sw	a5,64(s1)
  disk.desc = (struct virtq_desc *) disk.pages;
    80005fc8:	0001a797          	auipc	a5,0x1a
    80005fcc:	03878793          	addi	a5,a5,56 # 80020000 <disk+0x2000>
    80005fd0:	e398                	sd	a4,0(a5)
  disk.avail = (struct virtq_avail *)(disk.pages + NUM*sizeof(struct virtq_desc));
    80005fd2:	00018717          	auipc	a4,0x18
    80005fd6:	0ae70713          	addi	a4,a4,174 # 8001e080 <disk+0x80>
    80005fda:	e798                	sd	a4,8(a5)
  disk.used = (struct virtq_used *) (disk.pages + PGSIZE);
    80005fdc:	00019717          	auipc	a4,0x19
    80005fe0:	02470713          	addi	a4,a4,36 # 8001f000 <disk+0x1000>
    80005fe4:	eb98                	sd	a4,16(a5)
    disk.free[i] = 1;
    80005fe6:	4705                	li	a4,1
    80005fe8:	00e78c23          	sb	a4,24(a5)
    80005fec:	00e78ca3          	sb	a4,25(a5)
    80005ff0:	00e78d23          	sb	a4,26(a5)
    80005ff4:	00e78da3          	sb	a4,27(a5)
    80005ff8:	00e78e23          	sb	a4,28(a5)
    80005ffc:	00e78ea3          	sb	a4,29(a5)
    80006000:	00e78f23          	sb	a4,30(a5)
    80006004:	00e78fa3          	sb	a4,31(a5)
}
    80006008:	60e2                	ld	ra,24(sp)
    8000600a:	6442                	ld	s0,16(sp)
    8000600c:	64a2                	ld	s1,8(sp)
    8000600e:	6105                	addi	sp,sp,32
    80006010:	8082                	ret
    panic("could not find virtio disk");
    80006012:	00002517          	auipc	a0,0x2
    80006016:	76650513          	addi	a0,a0,1894 # 80008778 <syscalls+0x358>
    8000601a:	ffffa097          	auipc	ra,0xffffa
    8000601e:	512080e7          	jalr	1298(ra) # 8000052c <panic>
    panic("virtio disk has no queue 0");
    80006022:	00002517          	auipc	a0,0x2
    80006026:	77650513          	addi	a0,a0,1910 # 80008798 <syscalls+0x378>
    8000602a:	ffffa097          	auipc	ra,0xffffa
    8000602e:	502080e7          	jalr	1282(ra) # 8000052c <panic>
    panic("virtio disk max queue too short");
    80006032:	00002517          	auipc	a0,0x2
    80006036:	78650513          	addi	a0,a0,1926 # 800087b8 <syscalls+0x398>
    8000603a:	ffffa097          	auipc	ra,0xffffa
    8000603e:	4f2080e7          	jalr	1266(ra) # 8000052c <panic>

0000000080006042 <virtio_disk_rw>:
  return 0;
}

void
virtio_disk_rw(struct buf *b, int write)
{
    80006042:	7119                	addi	sp,sp,-128
    80006044:	fc86                	sd	ra,120(sp)
    80006046:	f8a2                	sd	s0,112(sp)
    80006048:	f4a6                	sd	s1,104(sp)
    8000604a:	f0ca                	sd	s2,96(sp)
    8000604c:	ecce                	sd	s3,88(sp)
    8000604e:	e8d2                	sd	s4,80(sp)
    80006050:	e4d6                	sd	s5,72(sp)
    80006052:	e0da                	sd	s6,64(sp)
    80006054:	fc5e                	sd	s7,56(sp)
    80006056:	f862                	sd	s8,48(sp)
    80006058:	f466                	sd	s9,40(sp)
    8000605a:	f06a                	sd	s10,32(sp)
    8000605c:	ec6e                	sd	s11,24(sp)
    8000605e:	0100                	addi	s0,sp,128
    80006060:	8aaa                	mv	s5,a0
    80006062:	8d2e                	mv	s10,a1
  uint64 sector = b->blockno * (BSIZE / 512);
    80006064:	00c52c83          	lw	s9,12(a0)
    80006068:	001c9c9b          	slliw	s9,s9,0x1
    8000606c:	1c82                	slli	s9,s9,0x20
    8000606e:	020cdc93          	srli	s9,s9,0x20

  acquire(&disk.vdisk_lock);
    80006072:	0001a517          	auipc	a0,0x1a
    80006076:	0b650513          	addi	a0,a0,182 # 80020128 <disk+0x2128>
    8000607a:	ffffb097          	auipc	ra,0xffffb
    8000607e:	b48080e7          	jalr	-1208(ra) # 80000bc2 <acquire>
  for(int i = 0; i < 3; i++){
    80006082:	4981                	li	s3,0
  for(int i = 0; i < NUM; i++){
    80006084:	44a1                	li	s1,8
      disk.free[i] = 0;
    80006086:	00018c17          	auipc	s8,0x18
    8000608a:	f7ac0c13          	addi	s8,s8,-134 # 8001e000 <disk>
    8000608e:	6b89                	lui	s7,0x2
  for(int i = 0; i < 3; i++){
    80006090:	4b0d                	li	s6,3
    80006092:	a0ad                	j	800060fc <virtio_disk_rw+0xba>
      disk.free[i] = 0;
    80006094:	00fc0733          	add	a4,s8,a5
    80006098:	975e                	add	a4,a4,s7
    8000609a:	00070c23          	sb	zero,24(a4)
    idx[i] = alloc_desc();
    8000609e:	c19c                	sw	a5,0(a1)
    if(idx[i] < 0){
    800060a0:	0207c563          	bltz	a5,800060ca <virtio_disk_rw+0x88>
  for(int i = 0; i < 3; i++){
    800060a4:	2905                	addiw	s2,s2,1
    800060a6:	0611                	addi	a2,a2,4 # 2004 <_entry-0x7fffdffc>
    800060a8:	19690c63          	beq	s2,s6,80006240 <virtio_disk_rw+0x1fe>
    idx[i] = alloc_desc();
    800060ac:	85b2                	mv	a1,a2
  for(int i = 0; i < NUM; i++){
    800060ae:	0001a717          	auipc	a4,0x1a
    800060b2:	f6a70713          	addi	a4,a4,-150 # 80020018 <disk+0x2018>
    800060b6:	87ce                	mv	a5,s3
    if(disk.free[i]){
    800060b8:	00074683          	lbu	a3,0(a4)
    800060bc:	fee1                	bnez	a3,80006094 <virtio_disk_rw+0x52>
  for(int i = 0; i < NUM; i++){
    800060be:	2785                	addiw	a5,a5,1
    800060c0:	0705                	addi	a4,a4,1
    800060c2:	fe979be3          	bne	a5,s1,800060b8 <virtio_disk_rw+0x76>
    idx[i] = alloc_desc();
    800060c6:	57fd                	li	a5,-1
    800060c8:	c19c                	sw	a5,0(a1)
      for(int j = 0; j < i; j++)
    800060ca:	01205d63          	blez	s2,800060e4 <virtio_disk_rw+0xa2>
    800060ce:	8dce                	mv	s11,s3
        free_desc(idx[j]);
    800060d0:	000a2503          	lw	a0,0(s4)
    800060d4:	00000097          	auipc	ra,0x0
    800060d8:	d92080e7          	jalr	-622(ra) # 80005e66 <free_desc>
      for(int j = 0; j < i; j++)
    800060dc:	2d85                	addiw	s11,s11,1
    800060de:	0a11                	addi	s4,s4,4
    800060e0:	ff2d98e3          	bne	s11,s2,800060d0 <virtio_disk_rw+0x8e>
  int idx[3];
  while(1){
    if(alloc3_desc(idx) == 0) {
      break;
    }
    sleep(&disk.free[0], &disk.vdisk_lock);
    800060e4:	0001a597          	auipc	a1,0x1a
    800060e8:	04458593          	addi	a1,a1,68 # 80020128 <disk+0x2128>
    800060ec:	0001a517          	auipc	a0,0x1a
    800060f0:	f2c50513          	addi	a0,a0,-212 # 80020018 <disk+0x2018>
    800060f4:	ffffc097          	auipc	ra,0xffffc
    800060f8:	0ce080e7          	jalr	206(ra) # 800021c2 <sleep>
  for(int i = 0; i < 3; i++){
    800060fc:	f8040a13          	addi	s4,s0,-128
{
    80006100:	8652                	mv	a2,s4
  for(int i = 0; i < 3; i++){
    80006102:	894e                	mv	s2,s3
    80006104:	b765                	j	800060ac <virtio_disk_rw+0x6a>
  disk.desc[idx[0]].next = idx[1];

  disk.desc[idx[1]].addr = (uint64) b->data;
  disk.desc[idx[1]].len = BSIZE;
  if(write)
    disk.desc[idx[1]].flags = 0; // device reads b->data
    80006106:	0001a697          	auipc	a3,0x1a
    8000610a:	efa6b683          	ld	a3,-262(a3) # 80020000 <disk+0x2000>
    8000610e:	96ba                	add	a3,a3,a4
    80006110:	00069623          	sh	zero,12(a3)
  else
    disk.desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
  disk.desc[idx[1]].flags |= VRING_DESC_F_NEXT;
    80006114:	00018817          	auipc	a6,0x18
    80006118:	eec80813          	addi	a6,a6,-276 # 8001e000 <disk>
    8000611c:	0001a697          	auipc	a3,0x1a
    80006120:	ee468693          	addi	a3,a3,-284 # 80020000 <disk+0x2000>
    80006124:	6290                	ld	a2,0(a3)
    80006126:	963a                	add	a2,a2,a4
    80006128:	00c65583          	lhu	a1,12(a2)
    8000612c:	0015e593          	ori	a1,a1,1
    80006130:	00b61623          	sh	a1,12(a2)
  disk.desc[idx[1]].next = idx[2];
    80006134:	f8842603          	lw	a2,-120(s0)
    80006138:	628c                	ld	a1,0(a3)
    8000613a:	972e                	add	a4,a4,a1
    8000613c:	00c71723          	sh	a2,14(a4)

  disk.info[idx[0]].status = 0xff; // device writes 0 on success
    80006140:	20050593          	addi	a1,a0,512
    80006144:	0592                	slli	a1,a1,0x4
    80006146:	95c2                	add	a1,a1,a6
    80006148:	577d                	li	a4,-1
    8000614a:	02e58823          	sb	a4,48(a1)
  disk.desc[idx[2]].addr = (uint64) &disk.info[idx[0]].status;
    8000614e:	00461713          	slli	a4,a2,0x4
    80006152:	6290                	ld	a2,0(a3)
    80006154:	963a                	add	a2,a2,a4
    80006156:	03078793          	addi	a5,a5,48
    8000615a:	97c2                	add	a5,a5,a6
    8000615c:	e21c                	sd	a5,0(a2)
  disk.desc[idx[2]].len = 1;
    8000615e:	629c                	ld	a5,0(a3)
    80006160:	97ba                	add	a5,a5,a4
    80006162:	4605                	li	a2,1
    80006164:	c790                	sw	a2,8(a5)
  disk.desc[idx[2]].flags = VRING_DESC_F_WRITE; // device writes the status
    80006166:	629c                	ld	a5,0(a3)
    80006168:	97ba                	add	a5,a5,a4
    8000616a:	4809                	li	a6,2
    8000616c:	01079623          	sh	a6,12(a5)
  disk.desc[idx[2]].next = 0;
    80006170:	629c                	ld	a5,0(a3)
    80006172:	97ba                	add	a5,a5,a4
    80006174:	00079723          	sh	zero,14(a5)

  // record struct buf for virtio_disk_intr().
  b->disk = 1;
    80006178:	00caa223          	sw	a2,4(s5)
  disk.info[idx[0]].b = b;
    8000617c:	0355b423          	sd	s5,40(a1)

  // tell the device the first index in our chain of descriptors.
  disk.avail->ring[disk.avail->idx % NUM] = idx[0];
    80006180:	6698                	ld	a4,8(a3)
    80006182:	00275783          	lhu	a5,2(a4)
    80006186:	8b9d                	andi	a5,a5,7
    80006188:	0786                	slli	a5,a5,0x1
    8000618a:	973e                	add	a4,a4,a5
    8000618c:	00a71223          	sh	a0,4(a4)

  __sync_synchronize();
    80006190:	0ff0000f          	fence

  // tell the device another avail ring entry is available.
  disk.avail->idx += 1; // not % NUM ...
    80006194:	6698                	ld	a4,8(a3)
    80006196:	00275783          	lhu	a5,2(a4)
    8000619a:	2785                	addiw	a5,a5,1
    8000619c:	00f71123          	sh	a5,2(a4)

  __sync_synchronize();
    800061a0:	0ff0000f          	fence

  *R(VIRTIO_MMIO_QUEUE_NOTIFY) = 0; // value is queue number
    800061a4:	100017b7          	lui	a5,0x10001
    800061a8:	0407a823          	sw	zero,80(a5) # 10001050 <_entry-0x6fffefb0>

  // Wait for virtio_disk_intr() to say request has finished.
  while(b->disk == 1) {
    800061ac:	004aa783          	lw	a5,4(s5)
    800061b0:	02c79163          	bne	a5,a2,800061d2 <virtio_disk_rw+0x190>
    sleep(b, &disk.vdisk_lock);
    800061b4:	0001a917          	auipc	s2,0x1a
    800061b8:	f7490913          	addi	s2,s2,-140 # 80020128 <disk+0x2128>
  while(b->disk == 1) {
    800061bc:	4485                	li	s1,1
    sleep(b, &disk.vdisk_lock);
    800061be:	85ca                	mv	a1,s2
    800061c0:	8556                	mv	a0,s5
    800061c2:	ffffc097          	auipc	ra,0xffffc
    800061c6:	000080e7          	jalr	ra # 800021c2 <sleep>
  while(b->disk == 1) {
    800061ca:	004aa783          	lw	a5,4(s5)
    800061ce:	fe9788e3          	beq	a5,s1,800061be <virtio_disk_rw+0x17c>
  }

  disk.info[idx[0]].b = 0;
    800061d2:	f8042903          	lw	s2,-128(s0)
    800061d6:	20090713          	addi	a4,s2,512
    800061da:	0712                	slli	a4,a4,0x4
    800061dc:	00018797          	auipc	a5,0x18
    800061e0:	e2478793          	addi	a5,a5,-476 # 8001e000 <disk>
    800061e4:	97ba                	add	a5,a5,a4
    800061e6:	0207b423          	sd	zero,40(a5)
    int flag = disk.desc[i].flags;
    800061ea:	0001a997          	auipc	s3,0x1a
    800061ee:	e1698993          	addi	s3,s3,-490 # 80020000 <disk+0x2000>
    800061f2:	00491713          	slli	a4,s2,0x4
    800061f6:	0009b783          	ld	a5,0(s3)
    800061fa:	97ba                	add	a5,a5,a4
    800061fc:	00c7d483          	lhu	s1,12(a5)
    int nxt = disk.desc[i].next;
    80006200:	854a                	mv	a0,s2
    80006202:	00e7d903          	lhu	s2,14(a5)
    free_desc(i);
    80006206:	00000097          	auipc	ra,0x0
    8000620a:	c60080e7          	jalr	-928(ra) # 80005e66 <free_desc>
    if(flag & VRING_DESC_F_NEXT)
    8000620e:	8885                	andi	s1,s1,1
    80006210:	f0ed                	bnez	s1,800061f2 <virtio_disk_rw+0x1b0>
  free_chain(idx[0]);

  release(&disk.vdisk_lock);
    80006212:	0001a517          	auipc	a0,0x1a
    80006216:	f1650513          	addi	a0,a0,-234 # 80020128 <disk+0x2128>
    8000621a:	ffffb097          	auipc	ra,0xffffb
    8000621e:	a5c080e7          	jalr	-1444(ra) # 80000c76 <release>
}
    80006222:	70e6                	ld	ra,120(sp)
    80006224:	7446                	ld	s0,112(sp)
    80006226:	74a6                	ld	s1,104(sp)
    80006228:	7906                	ld	s2,96(sp)
    8000622a:	69e6                	ld	s3,88(sp)
    8000622c:	6a46                	ld	s4,80(sp)
    8000622e:	6aa6                	ld	s5,72(sp)
    80006230:	6b06                	ld	s6,64(sp)
    80006232:	7be2                	ld	s7,56(sp)
    80006234:	7c42                	ld	s8,48(sp)
    80006236:	7ca2                	ld	s9,40(sp)
    80006238:	7d02                	ld	s10,32(sp)
    8000623a:	6de2                	ld	s11,24(sp)
    8000623c:	6109                	addi	sp,sp,128
    8000623e:	8082                	ret
  struct virtio_blk_req *buf0 = &disk.ops[idx[0]];
    80006240:	f8042503          	lw	a0,-128(s0)
    80006244:	20050793          	addi	a5,a0,512
    80006248:	0792                	slli	a5,a5,0x4
  if(write)
    8000624a:	00018817          	auipc	a6,0x18
    8000624e:	db680813          	addi	a6,a6,-586 # 8001e000 <disk>
    80006252:	00f80733          	add	a4,a6,a5
    80006256:	01a036b3          	snez	a3,s10
    8000625a:	0ad72423          	sw	a3,168(a4)
  buf0->reserved = 0;
    8000625e:	0a072623          	sw	zero,172(a4)
  buf0->sector = sector;
    80006262:	0b973823          	sd	s9,176(a4)
  disk.desc[idx[0]].addr = (uint64) buf0;
    80006266:	7679                	lui	a2,0xffffe
    80006268:	963e                	add	a2,a2,a5
    8000626a:	0001a697          	auipc	a3,0x1a
    8000626e:	d9668693          	addi	a3,a3,-618 # 80020000 <disk+0x2000>
    80006272:	6298                	ld	a4,0(a3)
    80006274:	9732                	add	a4,a4,a2
  struct virtio_blk_req *buf0 = &disk.ops[idx[0]];
    80006276:	0a878593          	addi	a1,a5,168
    8000627a:	95c2                	add	a1,a1,a6
  disk.desc[idx[0]].addr = (uint64) buf0;
    8000627c:	e30c                	sd	a1,0(a4)
  disk.desc[idx[0]].len = sizeof(struct virtio_blk_req);
    8000627e:	6298                	ld	a4,0(a3)
    80006280:	9732                	add	a4,a4,a2
    80006282:	45c1                	li	a1,16
    80006284:	c70c                	sw	a1,8(a4)
  disk.desc[idx[0]].flags = VRING_DESC_F_NEXT;
    80006286:	6298                	ld	a4,0(a3)
    80006288:	9732                	add	a4,a4,a2
    8000628a:	4585                	li	a1,1
    8000628c:	00b71623          	sh	a1,12(a4)
  disk.desc[idx[0]].next = idx[1];
    80006290:	f8442703          	lw	a4,-124(s0)
    80006294:	628c                	ld	a1,0(a3)
    80006296:	962e                	add	a2,a2,a1
    80006298:	00e61723          	sh	a4,14(a2) # ffffffffffffe00e <end+0xffffffff7ffdd00e>
  disk.desc[idx[1]].addr = (uint64) b->data;
    8000629c:	0712                	slli	a4,a4,0x4
    8000629e:	6290                	ld	a2,0(a3)
    800062a0:	963a                	add	a2,a2,a4
    800062a2:	058a8593          	addi	a1,s5,88
    800062a6:	e20c                	sd	a1,0(a2)
  disk.desc[idx[1]].len = BSIZE;
    800062a8:	6294                	ld	a3,0(a3)
    800062aa:	96ba                	add	a3,a3,a4
    800062ac:	40000613          	li	a2,1024
    800062b0:	c690                	sw	a2,8(a3)
  if(write)
    800062b2:	e40d1ae3          	bnez	s10,80006106 <virtio_disk_rw+0xc4>
    disk.desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
    800062b6:	0001a697          	auipc	a3,0x1a
    800062ba:	d4a6b683          	ld	a3,-694(a3) # 80020000 <disk+0x2000>
    800062be:	96ba                	add	a3,a3,a4
    800062c0:	4609                	li	a2,2
    800062c2:	00c69623          	sh	a2,12(a3)
    800062c6:	b5b9                	j	80006114 <virtio_disk_rw+0xd2>

00000000800062c8 <virtio_disk_intr>:

void
virtio_disk_intr()
{
    800062c8:	1101                	addi	sp,sp,-32
    800062ca:	ec06                	sd	ra,24(sp)
    800062cc:	e822                	sd	s0,16(sp)
    800062ce:	e426                	sd	s1,8(sp)
    800062d0:	e04a                	sd	s2,0(sp)
    800062d2:	1000                	addi	s0,sp,32
  acquire(&disk.vdisk_lock);
    800062d4:	0001a517          	auipc	a0,0x1a
    800062d8:	e5450513          	addi	a0,a0,-428 # 80020128 <disk+0x2128>
    800062dc:	ffffb097          	auipc	ra,0xffffb
    800062e0:	8e6080e7          	jalr	-1818(ra) # 80000bc2 <acquire>
  // we've seen this interrupt, which the following line does.
  // this may race with the device writing new entries to
  // the "used" ring, in which case we may process the new
  // completion entries in this interrupt, and have nothing to do
  // in the next interrupt, which is harmless.
  *R(VIRTIO_MMIO_INTERRUPT_ACK) = *R(VIRTIO_MMIO_INTERRUPT_STATUS) & 0x3;
    800062e4:	10001737          	lui	a4,0x10001
    800062e8:	533c                	lw	a5,96(a4)
    800062ea:	8b8d                	andi	a5,a5,3
    800062ec:	d37c                	sw	a5,100(a4)

  __sync_synchronize();
    800062ee:	0ff0000f          	fence

  // the device increments disk.used->idx when it
  // adds an entry to the used ring.

  while(disk.used_idx != disk.used->idx){
    800062f2:	0001a797          	auipc	a5,0x1a
    800062f6:	d0e78793          	addi	a5,a5,-754 # 80020000 <disk+0x2000>
    800062fa:	6b94                	ld	a3,16(a5)
    800062fc:	0207d703          	lhu	a4,32(a5)
    80006300:	0026d783          	lhu	a5,2(a3)
    80006304:	06f70163          	beq	a4,a5,80006366 <virtio_disk_intr+0x9e>
    __sync_synchronize();
    int id = disk.used->ring[disk.used_idx % NUM].id;
    80006308:	00018917          	auipc	s2,0x18
    8000630c:	cf890913          	addi	s2,s2,-776 # 8001e000 <disk>
    80006310:	0001a497          	auipc	s1,0x1a
    80006314:	cf048493          	addi	s1,s1,-784 # 80020000 <disk+0x2000>
    __sync_synchronize();
    80006318:	0ff0000f          	fence
    int id = disk.used->ring[disk.used_idx % NUM].id;
    8000631c:	6898                	ld	a4,16(s1)
    8000631e:	0204d783          	lhu	a5,32(s1)
    80006322:	8b9d                	andi	a5,a5,7
    80006324:	078e                	slli	a5,a5,0x3
    80006326:	97ba                	add	a5,a5,a4
    80006328:	43dc                	lw	a5,4(a5)

    if(disk.info[id].status != 0)
    8000632a:	20078713          	addi	a4,a5,512
    8000632e:	0712                	slli	a4,a4,0x4
    80006330:	974a                	add	a4,a4,s2
    80006332:	03074703          	lbu	a4,48(a4) # 10001030 <_entry-0x6fffefd0>
    80006336:	e731                	bnez	a4,80006382 <virtio_disk_intr+0xba>
      panic("virtio_disk_intr status");

    struct buf *b = disk.info[id].b;
    80006338:	20078793          	addi	a5,a5,512
    8000633c:	0792                	slli	a5,a5,0x4
    8000633e:	97ca                	add	a5,a5,s2
    80006340:	7788                	ld	a0,40(a5)
    b->disk = 0;   // disk is done with buf
    80006342:	00052223          	sw	zero,4(a0)
    wakeup(b);
    80006346:	ffffc097          	auipc	ra,0xffffc
    8000634a:	ffc080e7          	jalr	-4(ra) # 80002342 <wakeup>

    disk.used_idx += 1;
    8000634e:	0204d783          	lhu	a5,32(s1)
    80006352:	2785                	addiw	a5,a5,1
    80006354:	17c2                	slli	a5,a5,0x30
    80006356:	93c1                	srli	a5,a5,0x30
    80006358:	02f49023          	sh	a5,32(s1)
  while(disk.used_idx != disk.used->idx){
    8000635c:	6898                	ld	a4,16(s1)
    8000635e:	00275703          	lhu	a4,2(a4)
    80006362:	faf71be3          	bne	a4,a5,80006318 <virtio_disk_intr+0x50>
  }

  release(&disk.vdisk_lock);
    80006366:	0001a517          	auipc	a0,0x1a
    8000636a:	dc250513          	addi	a0,a0,-574 # 80020128 <disk+0x2128>
    8000636e:	ffffb097          	auipc	ra,0xffffb
    80006372:	908080e7          	jalr	-1784(ra) # 80000c76 <release>
}
    80006376:	60e2                	ld	ra,24(sp)
    80006378:	6442                	ld	s0,16(sp)
    8000637a:	64a2                	ld	s1,8(sp)
    8000637c:	6902                	ld	s2,0(sp)
    8000637e:	6105                	addi	sp,sp,32
    80006380:	8082                	ret
      panic("virtio_disk_intr status");
    80006382:	00002517          	auipc	a0,0x2
    80006386:	45650513          	addi	a0,a0,1110 # 800087d8 <syscalls+0x3b8>
    8000638a:	ffffa097          	auipc	ra,0xffffa
    8000638e:	1a2080e7          	jalr	418(ra) # 8000052c <panic>
	...

0000000080007000 <_trampoline>:
    80007000:	14051573          	csrrw	a0,sscratch,a0
    80007004:	02153423          	sd	ra,40(a0)
    80007008:	02253823          	sd	sp,48(a0)
    8000700c:	02353c23          	sd	gp,56(a0)
    80007010:	04453023          	sd	tp,64(a0)
    80007014:	04553423          	sd	t0,72(a0)
    80007018:	04653823          	sd	t1,80(a0)
    8000701c:	04753c23          	sd	t2,88(a0)
    80007020:	f120                	sd	s0,96(a0)
    80007022:	f524                	sd	s1,104(a0)
    80007024:	fd2c                	sd	a1,120(a0)
    80007026:	e150                	sd	a2,128(a0)
    80007028:	e554                	sd	a3,136(a0)
    8000702a:	e958                	sd	a4,144(a0)
    8000702c:	ed5c                	sd	a5,152(a0)
    8000702e:	0b053023          	sd	a6,160(a0)
    80007032:	0b153423          	sd	a7,168(a0)
    80007036:	0b253823          	sd	s2,176(a0)
    8000703a:	0b353c23          	sd	s3,184(a0)
    8000703e:	0d453023          	sd	s4,192(a0)
    80007042:	0d553423          	sd	s5,200(a0)
    80007046:	0d653823          	sd	s6,208(a0)
    8000704a:	0d753c23          	sd	s7,216(a0)
    8000704e:	0f853023          	sd	s8,224(a0)
    80007052:	0f953423          	sd	s9,232(a0)
    80007056:	0fa53823          	sd	s10,240(a0)
    8000705a:	0fb53c23          	sd	s11,248(a0)
    8000705e:	11c53023          	sd	t3,256(a0)
    80007062:	11d53423          	sd	t4,264(a0)
    80007066:	11e53823          	sd	t5,272(a0)
    8000706a:	11f53c23          	sd	t6,280(a0)
    8000706e:	140022f3          	csrr	t0,sscratch
    80007072:	06553823          	sd	t0,112(a0)
    80007076:	00853103          	ld	sp,8(a0)
    8000707a:	02053203          	ld	tp,32(a0)
    8000707e:	01053283          	ld	t0,16(a0)
    80007082:	00053303          	ld	t1,0(a0)
    80007086:	18031073          	csrw	satp,t1
    8000708a:	12000073          	sfence.vma
    8000708e:	8282                	jr	t0

0000000080007090 <userret>:
    80007090:	18059073          	csrw	satp,a1
    80007094:	12000073          	sfence.vma
    80007098:	07053283          	ld	t0,112(a0)
    8000709c:	14029073          	csrw	sscratch,t0
    800070a0:	02853083          	ld	ra,40(a0)
    800070a4:	03053103          	ld	sp,48(a0)
    800070a8:	03853183          	ld	gp,56(a0)
    800070ac:	04053203          	ld	tp,64(a0)
    800070b0:	04853283          	ld	t0,72(a0)
    800070b4:	05053303          	ld	t1,80(a0)
    800070b8:	05853383          	ld	t2,88(a0)
    800070bc:	7120                	ld	s0,96(a0)
    800070be:	7524                	ld	s1,104(a0)
    800070c0:	7d2c                	ld	a1,120(a0)
    800070c2:	6150                	ld	a2,128(a0)
    800070c4:	6554                	ld	a3,136(a0)
    800070c6:	6958                	ld	a4,144(a0)
    800070c8:	6d5c                	ld	a5,152(a0)
    800070ca:	0a053803          	ld	a6,160(a0)
    800070ce:	0a853883          	ld	a7,168(a0)
    800070d2:	0b053903          	ld	s2,176(a0)
    800070d6:	0b853983          	ld	s3,184(a0)
    800070da:	0c053a03          	ld	s4,192(a0)
    800070de:	0c853a83          	ld	s5,200(a0)
    800070e2:	0d053b03          	ld	s6,208(a0)
    800070e6:	0d853b83          	ld	s7,216(a0)
    800070ea:	0e053c03          	ld	s8,224(a0)
    800070ee:	0e853c83          	ld	s9,232(a0)
    800070f2:	0f053d03          	ld	s10,240(a0)
    800070f6:	0f853d83          	ld	s11,248(a0)
    800070fa:	10053e03          	ld	t3,256(a0)
    800070fe:	10853e83          	ld	t4,264(a0)
    80007102:	11053f03          	ld	t5,272(a0)
    80007106:	11853f83          	ld	t6,280(a0)
    8000710a:	14051573          	csrrw	a0,sscratch,a0
    8000710e:	10200073          	sret
	...
